23,409
社区成员




package notebook_test;
import java.util.ArrayList;
import java.util.Scanner;
public class Notebook {
private static ArrayList<String> notes = new ArrayList<String>();
private static Scanner sca;
public void add(String note) {
notes.add(note);
}
public int getSize() {
return notes.size();
}
public void printNotes(ArrayList<String> notes) {
for (String s : notes) {
System.out.print(s);
}
}
public static void main(String[] args) {
sca = new Scanner(System.in);
Notebook nb = new Notebook();
// Notebook nb1=new Notebook();
while (true) {
System.out.print("Enter notes: ");
nb.add(sca.nextLine());
System.out.print("Do you want to get size: ");
String str1 = sca.next();
if (str1.equals("Y") || str1.equals("y")) {
System.out.println("nb.getSize() "+nb.getSize());
}
System.out.print("Do you wan to print the notes: ");
String str2 = sca.next();
if (str2.equals("Y") || str2.equals("y")) {
nb.printNotes(notes);
System.out.println();
}
System.out.print("Do you wan to break: ");
String str3 = sca.next();
if (str3.equals("Y") || str3.equals("y")) {
System.out.println("==============================");
break;
}
}
}
}