Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3eb97d7

Browse filesBrowse files
committed
added ch10 examples
1 parent edd4f88 commit 3eb97d7
Copy full SHA for 3eb97d7

File tree

Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed
Open diff view settings
Collapse file

‎ch10/Append.java‎

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.Scanner;
2+
public class Append {
3+
public static void main(String[] args) {
4+
Scanner in = new Scanner(System.in);
5+
System.out.println("Enter 10 lines:");
6+
String text = "";
7+
for (int i = 0; i < 10; i++) {
8+
String line = in.nextLine(); // new string
9+
text = text + line + '\n'; // two more strings
10+
}
11+
System.out.print("You entered:\n" + text);
12+
}
13+
}
Collapse file

‎ch10/Surprise.java‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Surprise {
2+
public static void main(String[] args) {
3+
String s1 = "Hi, Mom!";
4+
String s2 = "Hi, " + "Mom!";
5+
if (s1 == s2) { // true!
6+
System.out.println("s1 and s2 are the same");
7+
}
8+
}
9+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.