I keep getting array dimension missing public static Planet readPlanets(String filename) { allPlanets = new Planet; In in = new In (filename); int nplanets = in.readInt(); double radius =...
  • April 4, 2022
  • 0 Comments
Solution is to use new String(c): System.out.println("" + new String(c)); And the "" + is really bogus and should be removed. Below is why you get what you get....
  • April 4, 2022
  • 0 Comments
A HashMap contains more than one key. You can use keySet() to get the set of all keys. team1.put("foo", 1); team1.put("bar", 2); will store 1 with key "foo" and...
  • April 4, 2022
  • 0 Comments
It keeps running because it hasn’t encountered EOF. At end of stream: read() returns -1. read(byte) returns -1. read(byte, int, int) returns -1. readLine() returns null. readXXX() for any...
  • April 3, 2022
  • 0 Comments
You would use List<List<String>> listOfLists = new ArrayList<List<String>>(); And then when you needed to add a new “row”, you’d add the list: listOfLists.add(new ArrayList<String>()); I’ve used this mostly when...
  • April 3, 2022
  • 0 Comments