4
Contributors
13
Replies
14
Views
8 Years
Discussion Span
Last Post by vijay24805
0

hi,,

i wanna ask one doubt in java 1.5
wats is the use of warraper classes????
how the integer.parseint() works wat does it takes as an input!!!!

and one more thing!!!!

while reading books i stuied that in java wat exer we give as an input is stores in the form of strings.... can u eloborate on it!!!!! if we give integer or float value is that also stores as an strings.... wats this string actually means is it like storing in the form of enlish alohabets or its like bits ??? pls eloborate

0

Its a bad idea to store integer values as Strings.

Basically strings are text. You cant do maths on strings

1 (integer) is not the same as "1" (a string). 1 + 1 = 2 but "1" + "1" = an error or "11"

0

Thanks for that clarification!!! on more thing:

what is the use of the wrapper classes!!! why we want to make a primitive into an object!!!!! cant we use primitive itself to perform the operations!!!

please clarify me on wrapper classes!!!

0

what is the use of the wrapper classes!!! why we want to make a primitive into an object!!!!! cant we use primitive itself to perform the operations!!!

please clarify me on wrapper classes!!

0

E.g String is a class so it has methods like .toLowerCase() etc... .Primitives like char or int dont support this.

0

import java.util.Scanner;
class ScanNext {
public static void main(String [] args) {
boolean b2, b;

int i;
String s, hits = " ";
Scanner s1 = new Scanner(args[0]);
Scanner s2 = new Scanner(args[0]);
while(b = s1.hasNext()) {
s = s1.next(); hits += "s";
}
while(b = s2.hasNext()) {
if (s2.hasNextInt()) {
i = s2.nextInt(); hits += "i";
} else if (s2.hasNextBoolean()) {
b2 = s2.nextBoolean(); hits += "b";
} else {
s2.next(); hits += "s2";
}
}
System.out.println("hits " + hits);
}
}

If this program is invoked with
% java ScanNext "1 true 34 hi"

it produces
hits ssssibis2


can u give explanation for this program!!!! how output has come like ssssibis2

0

ques1)why String class is marked as final?

ques2)whats the use of making String as immutable?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.