[5954] in java-interest

home help back first fref pref prev next nref lref last post

Re: tutorial question

daemon@ATHENA.MIT.EDU (Youngjin Roh)
Wed Mar 6 07:11:27 1996

Date: Wed, 6 Mar 1996 05:47:09 -0500 (EST)
From: Youngjin  Roh <yroh@gamera.syr.edu>
To: "Brad Q. Lucht" <blucht@sound.net>
Cc: java-interest@java.sun.com, lemay@lne.com, virtual@rendezvous.com
In-Reply-To: <1.5.4b11.32.19960305041203.0035e2c0@sound.net>


Hi.

I think the main function is also in the class which is the "main" class 
whose name is also same as your source file name.  Java is different from 
usual C program, so Java even doesn't have main function sometimes.

I am also novice in Java programming, so if I am wrong, please let me know.

Good luck.

> I am working through "Teach Yourself Java in 21 Days;" at this point it is
> more like 21 weeks.
> 
> I have a question about error statements I receive when I compile an example:
> 
>         Motorcycle.java:1: Identifier expected.
>         public static void main (String args[]) {
>               ^
>         Motorcycle.java:1: 'class' or 'interface' keyword expected.
>         public static void main (String args[]) {
>                ^
>         2 errors
> 
> For the life of me, I can't see what is wrong here.  Any explanation or
> guidance are appreciated
> 
> Here is the example, as I have typed it in:
> 
> public static void main (String args[]) {
> 	Motorcycle m = new Motorcycle();
> 	m.make = "yamaha RZ350";
> 	m.color = "yellow";
> 	System.out.println("Calling showAtts . . .");
> 	m.showAtts();
> 	System.out.println(". . . . . . . . .");
> 	System.out.println("Starting engine . . . ");
> 	m.startEngine();
> 	System.out.println(". . . . . . . . .");
> 	System.out.println("Calling showAtts . . .");
> 	m.showAtts();
> 	System.out.println(". . . . . . . . .");
> 	System.out.println("Starting engine . . . ");
> 	m.startEngine();
> }
> class Motorcycle {
> 
> 	String make;
> 	String color;
> 	boolean engineState;
> 
> 	void startEngine() {
> 		if (engineState == true)
> 			System.out.println("The engine is already on.");
> 		else 	{
> 			engineState = true;
> 			System.out.println("The engine is now on.");
> 		}
> 	}
> 	
> 	void showAtts() {
> 		System.out.println("This motorcycle is a "
> 			+ color + " " + make);
> 		if (engineState == true)
> 			System.out.println("The engine is on.");
> 		else System.out.println("The engine is off.");
> 	}
> }
> 
> -- Brad Lucht
> blucht@sound.net
> SD Engineering & Statistics
> Creative Thinking - Problem Solving
> 
> -
> This message was sent to the java-interest mailing list
> Info: send 'help' to java-interest-request@java.sun.com
> 
> -
> This message was sent to the java-interest mailing list
> Info: send 'help' to java-interest-request@java.sun.com
> 


================================================================
 This message was brought to you by  Youngjin Roh 
----------------------------------------------------------------
 Youngjin Roh        | yroh@gamera.syr.edu, yroh@rodan.syr.edu
 (315) 492-9282      | yroh@hydra.syr.edu, yroh@forbin.syr.edu
 211 Lafayette rd.   | emacro@chollian.dacom.co.kr, yroh@onKIDS
 #600, Syracuse,     | yroh in other BBSs.
 NY 13205, USA       | LOOK FOR IT IN A NEIGHBORHOOD NEAR YOU!
----------------------------------------------------------------
 Page me! --> 242-4634
----------------------------------------------------------------
 I'm building my WWW.  Try "http://web.syr.edu/~yroh"
----------------------------------------------------------------
 Computer Engineering, Grad., Syracuse University
================================================================





-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post