GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Trouble compiling my program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trouble compiling my program" Watch "Trouble compiling my program" New topic
Author

Trouble compiling my program

Stacey Lee
Greenhorn

Joined: May 08, 2003
Posts: 3
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

Joined: Apr 17, 2003
Posts: 327
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(" ------");
}
}


Thanks, leo
Stacey Lee
Greenhorn

Joined: May 08, 2003
Posts: 3
That worked perfect!!!
Thanks for your help Leo
 
GeeCON Prague 2014
 
subject: Trouble compiling my program