Docsity

Classes - Introduduction to Jave Programming - Lecture Slides, Slides of Java Programming

Partial preview of the text

Download Classes - Introduduction to Jave Programming - Lecture Slides and more Slides Java Programming in PDF only on Docsity!

Classes

Announcements

Midterm week? (Ours is Oct 19.) Lab progress? (Homework due on Monday)

methods

We have been using System.out.println() method since the second class In addition to using predefined methods (println() and Math.pow()) you can create your own. Useful if you are doing similar commands (if you copy and paste multiple lines of code)

methods

Can think of methods as packaging multiple commands into one

methods

(See: AddMethod.java) (See: NumberToDouble2.java) return type heading body return statement

methods

class

Classes are simply a way of organizing data (See: Lab2Part2Class.java) Docsity.com

class

Every time you do not make a primitive type (int, double, boolean, etc.) or String, you must use new command Basic format (syntax): [class] [identifier] = new class; Example: Partner p1 = new Partner(); Scanner in = new Scanner(System.in); Docsity.com

class

Classes make code much easier to modify in addition to organize Learning how to write code is practice, this will become natural if you do it a lot Writing code that can easily be added to is much more difficult

class

Can put a class inside another class (Ch 4.4)