lab1
. Make a new class Hello
. Be sure it is in the default package. Clear out the Package: field. Then paste in this code:
public class Hello { public static void main(String[] args) { System.out.println("Hello \uD83D\uDE3B!"); } }Run the program. What happens?
main
to Main
. Compile and run. What happens?System.out
to System.uot
. What happens?"
, i.e. before the );
. Type a period and to
. If nothing happens, hit Ctrl+Space. (Might be Option+Space on the Mac.) What happens?toUpperCase()
and run the program again. What happens?corejava/v1ch02/ImageViewer
whereever you unzipped the book code. Note that the project name is set to ImageViewer
. Click Finish.javac -versionWhat happens? (If you get an error message and don't know how to fix it, ask for help.)
corejava/v1ch02/Welcome
directory in the terminal.javac Welcome.java java WelcomeWhat happens?
javac Welcome? Why?
java Welcome.javaWhy?
hw1a
in Eclipse. Add two classes, Arrays
and Tester
. Copy/paste from CodeCheck. The Arrays
class should have your solution from the preceding page. What happens when you run it?Expected:
syntax. You'll need to compare the output yourself. Once you are satisfied, check it with CodeCheck.Tester
. Instead, the test cases are invisible. splice
method to
return "";Now run CodeCheck. What happens?
hw1b
and make classes Strings
and Tester
. In the Tester
class, do something similar to the Tester
class in the the first assignment. That is, print the values that you actually get when calling the method with the test arguments. Then print "Expected: HWeolrllod"
for the first test case, and similarly for the others.Strings
class. It tells you enough about strings that you should be able to translate your C++/C/Python solution. Ask for help if you can't. What is your Java solution?Tester
in Eclipse?int[] values = new int[1000000]; for (int i = 0; i < values.length; i++) values[i] = (int) (values.length *Math.sin(i));Let's sort it:
java.util.Arrays.sort(values);Let's see the first 10000 elements:
for (int i = 0; i < 10000; i++) System.out.println(values[i]);Put all this into a class
MostFrequent
and run it. What do you get?