954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

String problem

i got a problem wana display my String but it doesnt work

here is my code i dont understand why it doesnt print me anything.....

class StringDemo
{
public static void main(String[] args)
{
String s1,s2,s3,output;

s1=new String("hello");
s2=new String("hello guys");
s3=new String("happy birthday");

output="s1 = " +s1+ "\ns2 = " +s2+ "\ns3" +s3+;

}
}


help me not getting s1,s2,s3

extemer
Junior Poster
Banned
188 posts since Apr 2010
Reputation Points: -7
Solved Threads: 10
 

1. Applying text formatting on your post doesn't help you to get positive attention, so please do not use bold and italic formatting to make your post something special. Use it only to highlight important part in problem description not whole post
2. Use of code tags would be nice
3. Use of full English is expected
4. If you added System.out.println(output); you would see your combined string

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

ur code will not compile .... remove last '+' from your last line
ie remove below line
---------------------------------------
output="s1 = " +s1+ "\ns2 = " +s2+ "\ns3" +s3+;
-------------------------------------------
with

output="s1 = " +s1+ "\ns2 = " +s2+ "\ns3" +s3;

vchandra
Junior Poster in Training
73 posts since Mar 2010
Reputation Points: 13
Solved Threads: 14
 
class stringdemo
{
 public static void main(String[] args)
 {
  String s1,s2,s3,output;
  s1 = "hello";
  s2 = "hello guys";
  s3 = "happy birthday";
  output = "s1="+s1+"\ns2="+s2+"\ns3="+s3;
  System.out.print(output);
 }
 /*
 *By FlamingClaw.2010.04.05.Hungary
 */
}
FlamingClaw
Posting Pro
559 posts since Feb 2009
Reputation Points: 132
Solved Threads: 138
 

thnx man for help

extemer
Junior Poster
Banned
188 posts since Apr 2010
Reputation Points: -7
Solved Threads: 10
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You