You are on page 1of 2

Demo Example:public class Demo {

public static void main(String[] args) {


Demo d = new Demo();
String msg = d.getWish("Rama");
System.out.println(msg);
}
public String getWish(String name) {
return "good morning ! " + name;
}
}
Boxing, Un Boxing,Auto boxing,Parsing Example:public class Demo {
public static void main(String[] args) {
int a = 10; // Primitive data type
Integer b = 100; // Reference data type
Integer i = new Integer(a); // Boxing
int j = b.intValue(); // Unboxing
Integer k = a; // Auto Boxing
String s = "500";
int y = Integer.parseInt(s);// Parsing String to primitive type
int
float f = Float.parseFloat(s);// Parsing String to primitive
type float
long l = Long.parseLong(s); // Parsing String to primitive
type long
System.out.println("i value is.." + i);
System.out.println("j value is.." + j);
System.out.println("k value is.." + k);
System.out.println("y value is.." + y);
System.out.println("f value is.." + f);
System.out.println("l value is.." + l);

}
}

You might also like