Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

'class' or 'interface' expected

807598Jan 30 2006 — edited Jan 31 2006
I'm working through book examples about JavaBeans and this is my first attempt. My code is:
package com.wrox.cars;
 
import java.io.Serializable;
 
public class CarBean implements Serializable {
	
	public CarBean () {
	}
	
	private String make = "Ford";
	
	public String getMake() {
		return make;
	}
	
	public void setMake(String make) {
		this.make = make;
	}
}
I'm unable to compile my code because of the error:

/begjsp-ch04/CarBean.java:1: 'class' or 'interface' expected
package com.wrox.cars;
^
/begjsp-ch04/CarBean.java:3: 'class' or 'interface' expected
import java.io.Serializable;
^
2 errors

I copied this code directly from the book. Does the package mean that it won't compile anywhere but that location? I need some guidance, thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 28 2006
Added on Jan 30 2006
33 comments
543 views