Assignment05 - the number of bounces, whereas HashMap can...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
5.25 – public void enterNumber(String name, String number){ String newName = name; String newNumber = number; MapTester.put(name, number); } public String lookUpNumber(String name){ String getName = name; String number = MapTester.get(getName); System.out.println(number); } 5.26 – The key that was added last is the one that is final/will be used. 5.28 – You can have a Class.get(keyName) method to check whether or not the key exists, if a value is returned related to the input, then the key does exist. 5.29 – null is returned 5.32 – A HashSet is like an ArrayList because both are extensions to a function, they hold more than one value, they both use strings, and they use the add method. They are different only in their behaviors when used. 5.34 – By telling split to add a space after the input of a user. Search and locate all :’s inside of a string and replace them with a space.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5.53 – ArrayList, because ArrayLists and HashSets only need to store one variable, in this case
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the number of bounces, whereas HashMap can store multiple. ArrayList takes priority over HashSets because unlike sets ArrayLists keep the input placed in order. 5.58 – public final int tolerance = .001; private final int PassMark = 40; public final String help = “h”; 5.62 – The method does not work because the s String is being upper cased, but not stored as such. Another string needs to be created in order to hold the changes made to s. public void printUpper(String s) { String newString = s.toUpperCase(); System.out,println(newString); } 5.63 – When i1 is set to equal i2 the way it was (i1 = i2), the meaning of this is that i1 will always equal what i2 does in that particular parameter or method. Because of this, when i2 is changed on the next line/sequence, i1 is also changed as a result....
View Full Document

This note was uploaded on 03/31/2008 for the course CS 1705 taught by Professor Shedwards during the Spring '08 term at Virginia Tech.

Page1 / 2

Assignment05 - the number of bounces, whereas HashMap can...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online