• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding quotes within System.out.println()  RSS feed

 
James Allen A.
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to output the quotes as characters here. How do I get the compiler to output (without parenthesis) "Your problem is that "[whatever problem]" " This is what I tried.

I remember reading about using forward slashes to have compiler ignore text, but I'm not sure if that's what I'm supposed to use in this case.
 
smlsriram Srinivasan
Greenhorn
Posts: 2
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

yes. Backslash(\) will help to escape the special characters.

In your case,


public class Try {

public static void main(String a[]){
String problem = "[whatever problem]";
System.out.println("Your problem is that \"" + problem + "\"");
}
}

will do.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!