Hi what does this mean 5 + '7' + 2, i am pretty new to all this so please be patient with me, i write it down in the interactions window, and get 62. So far i know its some kind of math question, but what does it mean to write something in " ' ' "
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi what does this mean 5 + '7' + 2, i am pretty new to all this so please be patient with me, i write it down in the interactions window, and get 62. So far i know its some kind of math question, but what does it mean to write something in " ' ' "
When something is encased in '' it defines it as character.
Something encased in " " defines it as a string.
char someChar = 'b'; // Can only contain a single character
String someString = "This is a string"; // A string is just a collection of chars
I hadn't seen an equation like that but if I were to guess why it works is that the compiler is taking the dec value of the char and adding it into the equation. So it probably does 5 + value of char + 2. Someone with more experience will chime in and explain it better.
Hello.
If a character say c is enclosed in single quotes as 'c' then the expression 'c' returns the ASCII code of the character c.
So in your expression 5+'7'+2, three values are added: 5, ascii value of 7 which is 55, and 2.
So the sum comes to 62.
Syed.