• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help..

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
can someone explain the following with short examples. I am kind of lost trying to understand all these..
valueOf
toString
parseInt
intValue
- Thanks in advance.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi doit,
these are the methods defined in Integer class
1..valueOf
public static Integer valueOf(String s)
throws NumberFormatException
Returns a new Integer object initialized to the value of the specified String.

2..toString
public String toString()
Returns a String object representing this Integer's value
3..parseInt
public static int parseInt(String s)
throws NumberFormatException
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002d') to indicate a negative value
4..intValue
public int intValue()
Returns the value of this Integer as an int.
eg.
public class IntegerTest {

public static void main(String args[]){
Integer i = new Integer(124);

System.out.println(" intValue() = "+i.intValue());
System.out.println("toString() = "+i.toString());
System.out.println("valueOf = "+i.valueOf("124"));
System.out.println("parseInt = "+i.parseInt("124"));
}}
i hope this will help u to understand
manila
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and there are similar methods in the other wrapper classes also.
 
reply
    Bookmark Topic Watch Topic
  • New Topic