• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying 3 char in JOptionPane  RSS feed

 
Ken Mullins
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell me how I can get this to display in JptionPane ? It will display the first char but nothing else no matter what I put in the ()
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a char will hold only a char. You'll need something that holds multiple chars, such as a... String. And if you're concatenating chars into a String a StringBuffer is a convenient and efficient way to do this.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete stein wrote:a StringBuffer

StringBuilder is better unless you need the synchronization. In most cases you don't.
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oooh, you want to combine those 3 chars eh?

well create a single String, and then put those 3 char inside of it.
Done!
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:
pete stein wrote:a StringBuffer

StringBuilder is better unless you need the synchronization. In most cases you don't.


Indeed! Thanks for the correction!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!