Four Java files don't execute [message #1770457] |
Fri, 11 August 2017 18:32 |
RajibKumar Bandopadhyay Messages: 58 Registered: July 2014 |
Member |
|
|
I followed Joseph P. Russell's book, Learn Java In A Weekend, ISBN: 1-931841-60-8
There are four complete codes for one particular program, explaining subclass and superclass.
The four files in Automobile.java.zip don't compile and show errors. Why?
It is said:
Quote:Actually, you can add any
data type to a String literal, and the result will be interpreted as a String.
"The year is" + 2002
This creates a new string, even though the number 2002 isn't enclosed in quotation marks.
Java interprets anything that's added to a String literal as if it were itself a Java String
literal.The preceding code creates a new Java String : "The year is 2002".
But the codes are showing errors.
[Updated on: Fri, 11 August 2017 18:33] Report message to a moderator
|
|
|
|
Re: Four Java files don't execute [message #1770474 is a reply to message #1770467] |
Sat, 12 August 2017 06:07 |
RajibKumar Bandopadhyay Messages: 58 Registered: July 2014 |
Member |
|
|
Nitin Dahyabhai wrote on Fri, 11 August 2017 21:56What errors?
Could you please unzip the files and peruse them in your Eclipse Platform?
Please find attached the error file Four_Programs.csv for your kind perusal.
Outside of Eclipse, in the Terminal, I had:
javac Automobile.java
Automobile.java:38: illegal character: \8220
String s = "Number of wheels: " + numWheels;
^
Automobile.java:38: ';' expected
String s = "Number of wheels: " + numWheels;
^
Automobile.java:38: illegal character: \8220
String s = "Number of wheels: " + numWheels;
^
Automobile.java:38: not a statement
String s = "Number of wheels: " + numWheels;
^
Automobile.java:39: illegal character: \8220
s += "\nNumber of seats: " + numSeats;
^
Automobile.java:39: illegal character: \92
s += "\nNumber of seats: " + numSeats;
^
Automobile.java:39: ';' expected
s += "\nNumber of seats: " + numSeats;
^
Automobile.java:39: ';' expected
s += "\nNumber of seats: " + numSeats;
^
Automobile.java:39: illegal character: \8220
s += "\nNumber of seats: " + numSeats;
^
Automobile.java:39: not a statement
s += "\nNumber of seats: " + numSeats;
^
Automobile.java:40: illegal character: \8220
s += "\nColor: " + color;
^
Automobile.java:40: illegal character: \92
s += "\nColor: " + color;
^
Automobile.java:40: ';' expected
s += "\nColor: " + color;
^
Automobile.java:40: illegal character: \8220
s += "\nColor: " + color;
^
Automobile.java:40: not a statement
s += "\nColor: " + color;
^
Automobile.java:41: illegal character: \8220
s += "\nMileage: " + mileage;
^
Automobile.java:41: illegal character: \92
s += "\nMileage: " + mileage;
^
Automobile.java:41: ';' expected
s += "\nMileage: " + mileage;
^
Automobile.java:41: illegal character: \8220
s += "\nMileage: " + mileage;
^
Automobile.java:41: not a statement
s += "\nMileage: " + mileage;
^
Automobile.java:42: illegal character: \8220
s += "\nEngine running: " + engineRunning;
^
Automobile.java:42: illegal character: \92
s += "\nEngine running: " + engineRunning;
^
Automobile.java:42: ';' expected
s += "\nEngine running: " + engineRunning;
^
Automobile.java:42: illegal character: \8220
s += "\nEngine running: " + engineRunning;
^
Automobile.java:42: not a statement
s += "\nEngine running: " + engineRunning;
^
25 errors
javac AutomobileTest.java
AutomobileTest.java:12: illegal character: \8220
Automobile auto = new Automobile(4, 2, "red");
^
AutomobileTest.java:12: ';' expected
Automobile auto = new Automobile(4, 2, "red");
^
AutomobileTest.java:12: illegal character: \8221
Automobile auto = new Automobile(4, 2, "red");
^
AutomobileTest.java:12: ';' expected
Automobile auto = new Automobile(4, 2, "red");
^
AutomobileTest.java:13: illegal character: \8220
System.out.println("Created new automobile:");
^
AutomobileTest.java:13: ';' expected
System.out.println("Created new automobile:");
^
AutomobileTest.java:13: '(' or '[' expected
System.out.println("Created new automobile:");
^
AutomobileTest.java:13: illegal character: \8221
System.out.println("Created new automobile:");
^
AutomobileTest.java:13: ';' expected
System.out.println("Created new automobile:");
^
AutomobileTest.java:16: illegal character: \8220
System.out.println("Started Engine");
^
AutomobileTest.java:16: ';' expected
System.out.println("Started Engine");
^
AutomobileTest.java:16: illegal character: \8221
System.out.println("Started Engine");
^
AutomobileTest.java:16: not a statement
System.out.println("Started Engine");
^
AutomobileTest.java:18: illegal character: \8220
auto.color = "black";
^
AutomobileTest.java:18: illegal character: \8221
auto.color = "black";
^
AutomobileTest.java:18: not a statement
auto.color = "black";
^
AutomobileTest.java:19: illegal character: \8220
System.out.println("Painted it black");
^
AutomobileTest.java:19: ';' expected
System.out.println("Painted it black");
^
AutomobileTest.java:19: illegal character: \8221
System.out.println("Painted it black");
^
AutomobileTest.java:21: illegal character: \8220
System.out.println("Drove it 12.8 miles");
^
AutomobileTest.java:21: ';' expected
System.out.println("Drove it 12.8 miles");
^
AutomobileTest.java:21: not a statement
System.out.println("Drove it 12.8 miles");
^
AutomobileTest.java:21: ';' expected
System.out.println("Drove it 12.8 miles");
^
AutomobileTest.java:21: illegal character: \8221
System.out.println("Drove it 12.8 miles");
^
AutomobileTest.java:21: not a statement
System.out.println("Drove it 12.8 miles");
^
AutomobileTest.java:22: illegal character: \8220
System.out.println("Here are the results:");
^
AutomobileTest.java:22: ';' expected
System.out.println("Here are the results:");
^
AutomobileTest.java:22: ';' expected
System.out.println("Here are the results:");
^
AutomobileTest.java:22: illegal character: \8221
System.out.println("Here are the results:");
^
AutomobileTest.java:22: illegal start of expression
System.out.println("Here are the results:");
^
30 errors
javac Truck.java
Truck.java:47: illegal character: \8220
s += "\nHas trailer: " + hasTrailer;
^
Truck.java:47: illegal character: \92
s += "\nHas trailer: " + hasTrailer;
^
Truck.java:47: ';' expected
s += "\nHas trailer: " + hasTrailer;
^
Truck.java:47: illegal character: \8220
s += "\nHas trailer: " + hasTrailer;
^
Truck.java:47: not a statement
s += "\nHas trailer: " + hasTrailer;
^
Truck.java:48: illegal character: \8220
s += "\nTailer full: " + trailerFull;
^
Truck.java:48: illegal character: \92
s += "\nTailer full: " + trailerFull;
^
Truck.java:48: ';' expected
s += "\nTailer full: " + trailerFull;
^
Truck.java:48: illegal character: \8220
s += "\nTailer full: " + trailerFull;
^
Truck.java:48: not a statement
s += "\nTailer full: " + trailerFull;
^
Truck.java:49: illegal character: \8220
s += "\nTrailer mileage: " + trailerMileage;
^
Truck.java:49: illegal character: \92
s += "\nTrailer mileage: " + trailerMileage;
^
Truck.java:49: ';' expected
s += "\nTrailer mileage: " + trailerMileage;
^
Truck.java:49: illegal character: \8220
s += "\nTrailer mileage: " + trailerMileage;
^
Truck.java:49: not a statement
s += "\nTrailer mileage: " + trailerMileage;
^
15 errors
javac TruckTest.java
TruckTest.java:10: illegal character: \8220
Truck truck = new Truck("silver");
^
TruckTest.java:10: ';' expected
Truck truck = new Truck("silver");
^
TruckTest.java:10: illegal character: \8221
Truck truck = new Truck("silver");
^
TruckTest.java:10: ';' expected
Truck truck = new Truck("silver");
^
TruckTest.java:11: illegal character: \8220
System.out.println("Created a new truck:");
^
TruckTest.java:11: ';' expected
System.out.println("Created a new truck:");
^
TruckTest.java:11: not a statement
System.out.println("Created a new truck:");
^
TruckTest.java:11: ';' expected
System.out.println("Created a new truck:");
^
TruckTest.java:11: illegal character: \8221
System.out.println("Created a new truck:");
^
TruckTest.java:11: illegal start of expression
System.out.println("Created a new truck:");
^
TruckTest.java:15: illegal character: \8220
System.out.println("Started engine and attached trailer");
^
TruckTest.java:15: ';' expected
System.out.println("Started engine and attached trailer");
^
TruckTest.java:15: ';' expected
System.out.println("Started engine and attached trailer");
^
TruckTest.java:15: illegal character: \8221
System.out.println("Started engine and attached trailer");
^
TruckTest.java:17: illegal character: \8220
System.out.println("Loaded trailer");
^
TruckTest.java:17: ';' expected
System.out.println("Loaded trailer");
^
TruckTest.java:17: illegal character: \8221
System.out.println("Loaded trailer");
^
TruckTest.java:17: not a statement
System.out.println("Loaded trailer");
^
TruckTest.java:22: illegal character: \8220
System.out.println("Delivered load 127.75 miles away "
^
TruckTest.java:22: ';' expected
System.out.println("Delivered load 127.75 miles away "
^
TruckTest.java:22: not a statement
System.out.println("Delivered load 127.75 miles away "
^
TruckTest.java:22: ';' expected
System.out.println("Delivered load 127.75 miles away "
^
TruckTest.java:22: illegal character: \8220
System.out.println("Delivered load 127.75 miles away "
^
TruckTest.java:23: illegal character: \8220
+ "and drove back empty to get another load");
^
TruckTest.java:23: ';' expected
+ "and drove back empty to get another load");
^
TruckTest.java:23: ';' expected
+ "and drove back empty to get another load");
^
TruckTest.java:23: ';' expected
+ "and drove back empty to get another load");
^
TruckTest.java:23: illegal character: \8221
+ "and drove back empty to get another load");
^
28 errors
[Updated on: Sat, 12 August 2017 07:15] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08787 seconds