English

Differentiate between parselnt() and toString() functions.

Advertisements
Advertisements

Question

Differentiate between parselnt() and toString() functions.

Distinguish Between
Advertisements

Solution

Sr. No. parselnt() functions toString() functions
1. This method in the Integer wrapper class converts a string to an integer. This method in the Integer wrapper class converts a basic data type (int) to a string data type.
2. Example: 
int n; 
String s = "34"; 
n = Integer.parseInt(s); // converts "34" i.e. (String) to 34 i.e. (int) 
Example:
int n = 24; String s; 
s = Integer.toString(n); 

Now that s has the value "24", mathematical operations cannot be performed on it.

shaalaa.com
  Is there an error in this question or solution?
Chapter 2: Library Classes - EXERCISES [Page 179]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 2 Library Classes
EXERCISES | Q VII. 4. (b) | Page 179
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×