Java KeywordsPurposeclass (added 1/30/06)new (Added 1/30/06)package (Added 2/1/06)private (Added 2/3/06)public (Added 2/3/06)void (Added 2/8/06)extends (Added 2/15/06)this (Added 2/15/06)return (Added 2/17/06)super (added 3/1/06)interface (added 3/3/06)abstract (added 3/3/06)implements (added 3/3/06)Java KeywordsCSE 115Spring 2006Purpose•This set of slides contains a running list of the keywords that we have talked about so far this semester and a brief explanation of what each keyword does.class (added 1/30/06)•Indicates the start of the definition of a class.public class Name {}new (Added 1/30/06)•Indicates a call to a constructor•Used when you want to create a new instance of an object•Use:new constructorName();package (Added 2/1/06)•Indicates membership for a class in a particular package•Packages correspond to directories on the file system•Use:package nameOfPackage;private (Added 2/3/06)•Access control modifier (visibility) •Only accessible from within the classpublic (Added 2/3/06)•Access control modifier (visibility) •Accessible from everywhere and to everyonevoid (Added 2/8/06)•Used as a return type for a method.•Indicates that the method does not return anything.public void methodName() {}extends (Added 2/15/06)•Indicates that the class you are writing has a superclass, which is an indication of inheritance.public class ClassName extends SuperClassName {}this (Added 2/15/06)•Self-reference•Refers to the class itself•Can be used to have the class call its own methodthis.methodName();return (Added 2/17/06)•Needed to indicate what value is being returned from a method that has a return type.public NonVoidType methodName() {//do some workreturn someValue;}super (added 3/1/06)•Indicates a call to the superclass’ method (either constructor or just a regular method).public ConstructorName() {super(param);}public void OverriddenMethod() {super.OverriddenMethod();}interface (added 3/3/06)•Indicates the beginning of an interface definition.public interface InterfaceName {}abstract (added 3/3/06)•Indicates that a method is abstract (does not have a method body).public abstract void method();ORabstract public void method();implements (added 3/3/06)•Indicates that the class you are writing implements an interface.public class Name implements
View Full Document