• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Boxing n Auto boxing-marcus green

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if anyone can pass on the link where boxing and auto boxing is explained clearly......if there are any tips on this by marcus green....it wuld be even more helpful....im having k&&b....i need some other link....also about regex classes and pattern matching....thanks in advance.....
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
autoboxing

autoboxing addresses the code needed to get around the difference between primitives and the Wrapper classes used to store primitives. In the past it was necessary to call a method of the wrapper class to extract the primitive value. So the following code is typical.

With Java 1.5 it is possible to write

Note how the instance of the integer class is assigned directly to the int primitive without any need for conversion. Note that if you are using mock exams from earlier versions of Java you may find that the behaviour of JDK1.5 means the answer is �incorrect�, but that it is simply because of the effect of autoboxing.

.
 
shilpa Reddy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your explanation.......i have another doubt in formatting

int i1 = -123;
int i2 = 12345;

System.out.printf(">%0,7d< \n", i2);
System.out.format(">%+-7d< \n", i2);

result is

>012,345<
>+12345 <

can you explain me this......how did the comma go between 012 and y the - symbol was not inserted....

thanks...
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
--------------
System.out.printf(">%0,7d< \n", i2);
System.out.format(">%+-7d< \n", i2);
------------

7 represents the width of the output.
0 --> pad the o/p with zeros until it is of width 7
- --> left justifies the number and won't add - to the o/p
, --> is a grouping_separator.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic