To start the first program, open Jedit, then copy & paste the following code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
Save the code as the file named HelloWorld.java
Go to cmd windows in Windows OS or open terminal on MAC OS, then type
> javac HelloWorld.java
> java HelloWorld
See the output on the screen
Do the following exercises:
1. Replace "HelloWorld" by "Your name", then make a new line
System.out.println("We are SS-1201 students at the Faculty of Science, Universiti Brunei Darussalam");
2. Replace println by print
3. Use the println and print to make a STAR formation of symbol *
4. Try to remove ; from System.out.println("Hello, World"); save and compile the code to see the error!
5. Try to remove the inner bracket {}, save & compile the code to see error!
No comments:
Post a Comment