1. "Hello, World!"
  2. Variables and Types
  3. Arrays
  4. While, If, For
  5. ...Problem Set 0
  6. Static Methods
  7. Static Fields
  8. String Conversion
  9. Objects
  10. Threading
  11. Strings
  12. ...Problem Set 1.5
  13. Packages
  14. Complex Numbers
  15. Abstract classes
  16. Interfaces
  17. Autoboxing
  18. ...Problem Set 1
  19. enum
  20. Inner Classes
  21. Polymorphism
  22. Tanks!
  23. Callbacks
  24. Exceptions
  25. File I/O
  26. ...Problem Set 2
  27. Regular Expressions

...Problem Set 2

  1. The class java.io.OutputStream is an abstract class. Subclass and implement the abstract method to create a kind of output stream called a NumStream. Your NumStream class work in a similar fashion to the NumBuilder in problem set 1, converting digits to strings.
    NumStream.java
    1import java.io.*; 
    2public class NumStream extends OutputStream {
    3    public void write(int c) throws IOException {
    4        // What goes here?
    5    }
    6 
    7    public static void main(String[] args) {
    8        NumStream ns = new NumStream();
    9        PrintWriter pw = new PrintWriter(new OutputStreamWriter(ns));
    10        pw.println("123456789 and ! and # ");
    11        pw.flush(); // needed for anything to happen, try taking it out
    12    }
    13}
    $ javac NumStream.java
    
  2. Create a subclass of java.lang.RuntimeException called HashException and modify NumStream to throw it when your NumStream class encounters a hash character (#).
  3. Repeat the last exercise, but this time name your exception BangException and have it extend java.io.IOException. Run your code and observe the differences.
  4. The class java.io.File can be used to open directories (folders) and read their contents. Write a java program that uses File to open the current directory (named ".") and list the files present inside it. You will have to do some online research to learn more about java.io.File.