[Java] Escape sequence

Escape sequence

.


Apple
"Mandarin orange" 
melon

How should I fill in the mandarin oranges only when I want to emphasize them with "" (double quotation marks)? : thinking:

test.java


public class Main {
	public static void main(String[] args) {
		System.out.println("Apple");
		System.out.println(""Mandarin orange"");
		System.out.println("melon");
	}
}

When I added "" to the mandarin oranges as above, I got a compile error: weary: Escape sequences are used in such cases: smile: If you modify it to the following code that uses escape sequences ...

Example.java


public class Main {
	public static void main(String[] args) {
		System.out.println("Apple");
		System.out.println("¥"Mandarin orange ¥"");
		System.out.println("melon");
	}
}

console.


Apple
"Mandarin orange" 
melon

It was displayed properly: laughing:

The reason why I got an error earlier PC-kun judges from "to" as a character string.

In other words, "" mandarin orange "" There are no characters from "to", right? ?? It says mandarin oranges, but what is this? ?? Also, there are no characters from "to", right? ?? ... I will send it back. That means: scream:

To avoid that, put a \ in front of ", this is not a string". "What is it for you to display as characters?" Therefore, I will write \ "to distinguish it, so please display it as a character. That means: smile:

Therefore, if you put \ in front of the symbol you want to display, it will be displayed as a character. Some of them are listed below: smile:

Notation meaning
¥" "(Double quotation)
¥' '(Single quotation mark)
¥¥ ¥ (Yen mark)

Recommended Posts

[Java] Escape sequence
Java
Java
What is java escape analysis?
Java learning (0)
Studying Java ―― 3
[Java] array
[Java] Annotation
[Java] Module
Java array
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java Day 2018
java (array)
Java static
Java serialization
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
Studying Java ―― 1
[Java] Array
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
[Java] Inheritance
FastScanner Java
Java features
java beginner 3
Java memo
java (encapsulation)
Java inheritance
[Java] Overload
Java basics
Decompile Java
[Java] Annotation
java notes
java beginner
Java (add2)
JAVA (Map)
[java] interface
Java9 collection
Java basics
Java methods
Java diary
Java inheritance