{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Creating a Method

Creating a Method - Parameters-pass a parameter to the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Creating a Method - declare method o syntax: visibility returnType name(parameterList) visibility determines access (public/private) if nothing returned: void example: public void drawSquare(); - name method Adding a method to a class - type method at end of code o before last } - compile files before testing in interactions pane o clears all old variables Main methods - when you execute a class you can have a main method - main method: class (static) method o takes an array of strings o
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Parameters -pass a parameter to the method o parameter lists specify what type of thing is passed name to use to refer to the value in the method o ie: public void drawSquare(int width); Subclasses -inherits the methods and field o Turtle class is a subclass of SimpleTurtle o public class Turtle extends SimpleTurtle Can add new variables and new methods -Classes can subclass another class in Java and Alice...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online