Originally posted by Ramakrishna Nalla: I used name.. which is not intialized..Is strings automatically initialized to default.if Yes to what value they initialized..
name is not a String, it's a char. char's are initialized to 0 (== '\000') as default value.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Jan 08, 2005
Originally posted by Ramakrishna Nalla: Ok..as name indicates null character...How that output 195 came..Pls explain me in detail...
I have already explained it, see my previous posts. It is the addition of the ASCII values of the two chars: B(98) + A(97). I cannot see what it is that you find difficult to understand.
Joined: Apr 21, 2005
Ok I understand that one... Riaz. But I want to Know the details of Println() method. How this method treats each paratmeter..... When.will string concatenation occurs or when it will simply put char output. println()..
It has nothing to do with println. It's just how the expression
is evaluated. Expressions are evaluated from left to right. "name + name + name" is adding three numbers together. When you add a char and a char, you get an int containing the sum of the char values. So 97 + 0 + 98 is 195.
So then we can simplify to 195 + " " + name. Adding a number and a String converts the number to a printable representation, and then catenates it with the String, so you get "195 " from the first two terms. Likewise, adding a String and a char converts the char to a String containing that one char, and then catenates them, giving, in this case, "195 c". No surprises.