Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble compiling my program

 
Stacey Lee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I am VERY new to Java and I am having some trouble I am hoping you all can help me out. Below is the code for the program i am trying to run. When I compile the code I get the following error "Face.jave:8: illegal escape character
System.out.println("|\_/|");
Can someone help me and tell me what this means and how to fix it?
Thanks
Stacey
public class Face
{
public static void main(String[] args)
{
System.out.println(" /////");
System.out.println(" | o o |");
System.out.println("(| ^ |)");
System.out.println(" | \_/ |");
System.out.println(" ------");
}
}
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The '\' is an escape character meaning that it is looking for something like: \n, or \t.
Try this, use two escape characters \\_:
public class Face
{
public static void main(String[] args)
{
System.out.println(" /////");
System.out.println(" | o o |");
System.out.println("(| ^ |)");
System.out.println(" | \\_/ |");
System.out.println(" ------");
}
}
 
Stacey Lee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked perfect!!!
Thanks for your help Leo
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic