if (dogName.startsWith("P")) {
// Write the name to the file.
outputFile.println(dogName);
}
checkout the string api http://docs.oracle.com/javase/7/docs/api... - methods that you can use on string (dogName) are here.
Hope it helps!
Dude i know i should be helping but i want to ask you a question. Where did you java. Im trying to learn it online but no one explains anything properly.
import java.util.*;
import java.io.*;
public class Program {
public static void main(String[] args) {
List
saveTo("d:/temp/names.txt", filter(names));
}
private static List
List
for (int i = 0; i < 20; i++) {
System.out.print(message);
Scanner keyboard = new Scanner(System.in);
String input = keyboard.nextLine();
results.add(input);
}
return results;
}
private static List
List
for (String item : items) {
if (item.toLowerCase().startsWith("p")) {
results.add(item);
}
}
return results;
}
private static void saveTo(String fileName, List
File file = new File(fileName);
PrintWriter writer = null;
try {
writer = new PrintWriter(file);
for (String item : items) {
writer.println(item);
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} finally {
if (writer != null) writer.close();
}
}
}