Back to feed
Renewal·서른의 생활코딩

ex23) Java OOP - Wrapper Classes

NS
normalstory
cover image


//Wrapper class > Integer class : example

class IntegerExam1 {
public static void main(String args[]) {
Integer num1 = new Integer(13);
Integer num2 = new Integer(25);
int hap = num1.intValue() + num2.intValue();
System.out.println("num1 wraps the integer: : " + num1.intValue());
System.out.println("num2 wraps the integer: : " + num2.intValue());
System.out.println("sum of two numbers = " + hap);
System.out.println("binary representation of the sum : " + Integer.toBinaryString(hap));
System.out.println("octal representation of the sum : " + Integer.toOctalString(hap));
System.out.println("if(num1 == num2) : " + num1.equals(num2));
Integer num3 = new Integer("444");
// creating integer object using string
System.out.println("value of string '444' is : " + num3.intValue());
}
}










//System class : example

class SystemExam {
public static void main(String args[]) {
long start,end;
start=System.currentTimeMillis();
System.out.println("current time :"+start);
System.out.println("5000times loopstart");
for(int i=0; i<5000; i++);
System.out.println("5000times loopend");
end=System.currentTimeMillis();
System.out.println(" loopendtime:" +end);
System.out.println(" loopelapsed time:" +(end-start))
;
}
}








 

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.

More on the author's page

Keep reading

Renewal

Steadily, for the long haul, without burning out

Mar 31, 2026·9 min
Renewal

Tech-life balance

Feb 7, 2026·3 min
Renewal

Humanality, by Park Jeong-ryeol

Feb 7, 2026·11 min