태그 » Java

Collections in java

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeSet;

public class AllaryListConcept {

public static void main(String[] args) {
// ArrayList al=new ArrayList(); 97단어 남음

Hash map concept Java

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public class HashMapConcept {
public static void main(String[] args) {
//HashMap<String,String> hm= new HashMap();
TreeMap<String,String> hm= new TreeMap();
hm.put(“ID”, “121”); 30단어 남음

Addition of Even numbers upto given number in java

import java.util.Arrays;

public class NoOperations {

public void evennumberaddition(int n) {
int total = 0;
for(int i=1;i<=n;i++) {
if(i%2==0) {
total = total + i; 24단어 남음

Addition of odd numbers up to given number in java

import java.util.Arrays;

public class NoOperations {

public void oddnumberaddtion(int n) {
int total = 0;
for(int i=1; i<n; i++) {
if(i%2==0) {
total = total + i; 34단어 남음

Decimal to binary conversion in java

import java.util.Arrays;

public class NoOperations {

public void decimaltobinary(int n) {
int[] binarynum = new int;
int org = n;
int i = 0;
while(n>0) { 44단어 남음

Find Duplicate element in array

public class Armstrongno {

public void checkarmstrong(int n) {
int temp=n;
int a,c=0;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a*a);
}
if(temp==c)
System.out.println(“armstrong number”);
else
System.out.println(“Not armstrong number”); 28단어 남음

Check For Armstrong number in java

public class Armstrongno {

public void checkarmstrong(int n) {
int temp=n;
int a,c=0;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a*a);
}
if(temp==c)
System.out.println(“armstrong number”);
else
System.out.println(“Not armstrong number”); 28단어 남음