Download presentation
Presentation is loading. Please wait.
1
Java Coding in Eclipse 1 CS440
2
Eclipse basics Written in Java Based on Equinox frameworkEquinox Modular Java specification OSGi (Open Services Gateway initiative)OSGi Dynamically loaded modules: bundles Android Development Tools (ADT) plug-in: Bundle CS440 2
3
Eclipse Environments Java Runtime Environment Integrated Development Environment (IDE) Modify eclipse.ini Java Compiler: .class files Error messages, autocompletion (ctrl+space) Application Runtime Where the android emulator runs Android Virtual Device (AVD) CS440 3
4
Eclipse basic ingredients Workspace File → Switch Workspace → Others Perspective Window → Open Perspective → Other Views and Editors Java Perspective and Package Explorer More info at: http://www.vogella.de/articles/Eclipse/article.html #eclipsesui CS440 4
5
Eclipse Workspace Keeps project state Organized in directories Different settings for different workspaces Ex. AndroidProjects CS440 5
6
Eclipse Projects Java Project vs Android Project Different plugins Builder: generates artifacts Transforms.class files to.dex files Association Open with.. CS440 6
7
Eclipse Views and perspectives Package explorer Task list: todo list Outline: code hierarchy Problems: compiler errors, builder errors. Other views? CS440 7
8
New Project: CarDealership Classes Car Public void drive(): prints “Going down the road” Ragtop extends Car JoyRide driveCars Test the Car class using: a main method in the drive cars class Create object: myCar test CS440 8
9
More Java: Object class 9 CS440
10
Objects and classes Class: Fields (data) Methods (procedures) Class that inherits from another: subtype or subclass Parent class: supertype or superclass CS440 10
11
Class Trivial Create a trivial class with: Fields: private long ctr Methods: public void incr(): Increases ctr by 1 every time it is called Constructor that takes as input ling initCtr Constructor that initializes ctr to 0 CS440 11
12
Object class and its methods http://docs.oracle.com/javase/6/docs/api/java/la ng/Object.html http://docs.oracle.com/javase/6/docs/api/java/la ng/Object.html toString equals CS440 12
13
Objects, Inheritance, and Polymorphism Objects of single type can have different behavior Subtype are declared with extends keyword Example: Cars! CS440 13
14
Continue Project: CarDealership Classes Car Public void drive(): prints “Going down the road” Ragtop extends Car Extend drive method to: Print: “top down!” Use superclass method Print” “Got the radio on!” Test ragtop CS440 14
15
Continue Project: CarDealership Class Joyride: Fields: private Car myCar Methods: Public void park(Car) Assing field mycar to the argument Public Car whatsInTheGarage() Return car Public void letsGo() Call park to park a new Ragtop Call whatsInTheGarage and drive it! Test JoyRide CS440 15
16
References Programming Android by Zigurd Mednieks, Laird Dornin, G. Blake Meike, Masumi Nakamura Eclipse http://www.vogella.de/articles/Eclipse/article.html #eclipsesui CS440 16
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.