Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String problem

 
Will Walder
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a code in TexPad with a String:
String s ="";
When I copy/paste a text inside the double quotes and compile the program I got a syntax error: unclosed string literal. Could somebody help, please?
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the String you are putting in to it? If it contains " you need to escape them so that it would look like
String s = "Hello to all my \"good\" buddys";
instead of
String s = "Hello to all my "good" buddys";
 
Greg Brouelette
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the text you're pasting in have either a quote or a slash in it? Show me the line after you've pasted text into it. I have a feeling either there is a quote in that text or the last character may be a slash which would be "escaping" the close quote.
Post the line after you've pasted the text and we'll figure it out.
 
Will Walder
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
If I copy/paste e.g. sentence from your message: (What is the String you are putting in to it?) it works fine, but when I try to put a stock quote information from PopUp window inside the double quotes, like
1.65 300 UUB CAA 19:56:33
1.65 100 EEE BEA 19:54:57
1.65 200 TRA TRA 19:53:22
I got that a syntax error message.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ensure when you paste it in that the pasted text doesn't end in a line feed. If it winds up like
String s = "1.65 300 UUB CAA 19:56:33
";
You'll get this.
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep in mind that you everything in the quotes must be on one line. You can use the \n escape character to indicate where the new line should start.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic