-1

1>Integer ie = Integer.valueOf("45");//give output 45

2>int ie = Integer.valueof("45");//give same output as 45

// can you tell me difference between 1 and second statement

3>Integer i3 = Integer.valueOf("70");//give output as 70

4>int i3 = Integer.valueOf("70");// also give same output

0

2 Answers 2

1

Its called unBoxing in java which was introduced in JAVA 5 Integer is wrapper class which provides Integer object to un-boxed into int primitive data type. Integer has static methods like

static Integer valueOf(int i) static Integer valueOf(String s) static Integer valueOf(String s, int radix) 

Similar wrapper classes for other primitive data types

byte has Byte short has Short int has Integer long has Long boolean has Boolean char has Character float has Float double has Double 
Sign up to request clarification or add additional context in comments.

Comments

0

The first query gives you an Objectof type Integer.

The second query gives you a primitive type int. That will be the same as Integer.valueof("45").intValue();

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.