Small Java Programs
This chapter discusses naming and coding conventions as well as reserved words in Java. When you go through this chapter, you'll get some hands-on experience with writing in Java.
9. Fixing Errors
Answer:
The reserved word String
has been changed to string
. The other changes in case are OK.
The class name hello
is OK. Class names are your choice. It is usual to start class names with
upper case, but OK not to. The characters inside quotes can be (nearly) anything you want.
Fixing Errors
Usually you will have two windows open on your computer: one for a text editor (such as Notepad or Notepad++) and one for the command interpreter.
To fix the syntax error, change the "C" to a "c" and save the file. Now use javac
to compile the source file, and if there are no errors, use java
to run it.
Question 9:
If you forget to save the file after making the change, and then enter the command javac Hello.java
, what will happen?