wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes need help. please. PLEASE! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need help. please. PLEASE!" Watch "need help. please. PLEASE!" New topic
Author

need help. please. PLEASE!

David Crane
Greenhorn

Joined: Aug 29, 2009
Posts: 15
ok I keep getting messages that say illegal escape character. and I don't have any idea what one is. here's a copy of my code. I've gotta make it so it displays a image made of characters


package maincharactepicture;

public class Main {
public static void main(String[]args)
{
System.out.println(" /\ " );
System.out.println(" / \ " );
System.out.println(" /_ _\ " );
System.out.println(" -----// \ / \\----- " );
System.out.println(" / // / \ \\ \ " );
System.out.println("--------------------/----//---/- -\---\\----\------------------- " );
System.out.println(" l ll l " );
System.out.println(" 0 00 0 " );
}

}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

A couple of points, David.

1. Welcome to the Ranch.

2. Please use a meaningful subject line.

3. Watch your tone. I've removed some objectionable language from your post.

4. The backslash character has special meaning in Java string literals.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

And ...

5. Please use code tags when posting code.
David Crane
Greenhorn

Joined: Aug 29, 2009
Posts: 15
ok thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

Did the hint in bold help?
David Crane
Greenhorn

Joined: Aug 29, 2009
Posts: 15
yes, would you know a way to use a backslash without that problem? I have to make a picture and I need a backslash to do so
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

A little research on Java string literals will tell you that the backslash is the "escape" character that is used to introduce special characters into the string. For example, the sequence "\n" will create a newline character. To create a backslash itself you escape the backslash character -- in other words, use a double backslash to represent the backslash character.
David Crane
Greenhorn

Joined: Aug 29, 2009
Posts: 15
ok I'll try it

i9t worked, thank you very much
 
Consider Paul's rocket mass heater.
 
subject: need help. please. PLEASE!