• Post Reply Bookmark Topic Watch Topic
  • New Topic

confused  RSS feed

 
kevinn lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why doesnt the "kkkk" print when it is following c[5] and prints when its preceeding c[5]?
thanks
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this and this. What sort of results and what sort of errors are you getting?

What type of variable is c[5]? Is it initialised to anything? Read in the Java™ Language Specification what sort of value a char is. Note what sort of values the "+" operator can take; some details are just below the link I have just given you; you might find others here.

Now, what is going to happen when you have a number to the left of the + operator and a String on its right?
What happens when it is the other way round?
If you print out 0 as a char, what does it look like?
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, when I tried it, I did get it to print kkkk.
 
kevinn lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome

And what did you work out from your reading?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!