SlideShare a Scribd company logo
Mobile Programming with J2ME
               By Oluwatosin Adesanya
Lesson 01:
Basic Java Programming
Java is ...
     •   A Pure OOP Language
     •   A Hybrid Programming Language
     •   First Compiled and Interpreted
     •   Runs on a JVM (Java Virtual Machine)



                      Byte Code




Source                                          Object
 Code                                           Code
Getting Started

• JDK (Java Development Kit)
• Editor (Notepad) OR ...
• Integrated Development Environment (Netbeans, Eclipse,
  JCreator etc.)
Setting Up Java

• Install the JDK
• The JDK Sits in C:Program FilesJavajdk1.6.0
• Set the PATH Environmental Variable (How?)
Setting the PATH Environmental Variable

Open your Systems Property: choose Advanced System Settings, Click
the Environmental Variable Button on the Dialog that shows Up
Setting the PATH Environmental Variable

Scroll and Select Path , Click Edit Button
Setting the PATH Environmental Variable

Append the current path with the path to the Java bin folder
Running Java

• Save your Java source code as a .java file
• Use the javac Command to compile your source codes (.java files)
  e.g javac Result.java
• A .class file is generated called a bytecode
• Use java Command to run the .class file e.g java Result
• Do not add .class when compiling




      Source                                          Object
                  javac     Byte Code     java
       Code                                           Code
The Structure of a Java Program

• Java Programs are made up of classes
• Classes are made up of methods
• Java existing (ready-made) classes are found in the Java Class
  Libraries (Also Called Java APIs)
• Execution of Java programs begin at the main method
A Simple Java Program


public class HelloWorld {
  public static void main(String[] args) {
      System.out.println("Hello World!");
  }
}
Classes and Objects

• A Class is like a factory from which Objects are churned Out.

   Example
   Class Car could produce objects Volkswagen bettles, Toyota Camri,
   Peugeout 306

   An Object is a model of the Real World and has
   States (Or Properties) and
   Behaviours (Or Actions)

   Example
   Object Car States are Color, Speed, Size, Plate Licence No, Cost
   Behaviours are Start, Stop, Accelerate, Fuel, Open Door, etc.
Creating a Class

Use the class Keyword

Example
public class HelloWorld {
          .
          .
          .
    }

Do NOT Forget!
Name your java file ClassName.java
Adding States (Properties)

• States in Java are simply variables (Otherwise called fields)

   Example

   public class PaySlip {
       int numdone;
       String name;
   }


   Observe?!
   Every Line of Java code ends with a semicolon (;)

  int,float, double,
  boolean, char … are Java Primitive Types
Adding Behaviours (Methods)

•   Methods are functions that control states or fields or variables. They
    change the state of an object.

    Example

    public class PaySlip {
        int numdone;
        String name;

         public double getPay() {
               return 40.00 * numdone;
         }
                                                         Method getPay()
    }


    Guess What? We already have a working Java Class!
Using Our Class PaySlip

We implement another tester class which
contains the main method.


public class TestPaySlip {
      public static void main(String[] args){
            PaySlip opay=new PaySlip();
            System.out.println("n"+opay.getPay());
      }
}
Constructors

•   Initializes the Object after memory allocation
•   Takes the same name as the Class
•   May accept parameters OR... may not
•   Every Class has a default constructor that accepts no parameter
•   Has No Return Type
•   Can be Overloaded (there can be multiple Constructors)
Constructors
public class PaySlip {
   int numdone;
   String name;

    public PaySlip(int numdone, String name) {
        this.numdone=numdone; this.name=name;
    }

    public PaySlip(){
        name=“Nobody”;
        numdone=0;
    }

    public double getPay() {
        return 40.00 * numdone;
    }
}
Sorry...



• Confused?
• Questions?
Lesson 02:
Java 2 Micro Edition(J2ME)
J2ME is ...

•   Java for small devices
•   Divided into Configurations, Profiles and Optional APIs

    Configurations, Profiles and Optional APIs combined together make up
    a stack

    Configurations: Specifies a JVM. We have CDC and CLDC

    CLDC (Connected Limited Device Configuration) is designed for
    devices with limited memory, displays, battery power and inputs.

    Profiles: Layered on top of CLDC and adds APIs for specific devices.
    We have MIDP, PDAP and Personal Profiles

    MIDP (Mobile Information Device Profile) has characteristics that makes
    most low end phones and PDAs fit in. J2ME is covered by MIDPs
Anatomy of MIDP Apps
MIDP Apps are ...

• Called MIDlets
• Portable
• Secured
• represented by instances of
  javax.microedition.midlet.MIDlet class
• Distributed as JAR (Java Archive) files along with a MANIFEST file
  and an Application Descriptor File (.jad file)
• Reduced to small sizes before distribution by an Obfuscator




    Popular J2ME Apps: Opera Mini, 2go, Go Bible
The MIDlet Life Cycle
Shall We Create a MIDlet?

package com.thinkit2ru;

import javax.microedition.midlet.*;

public class Metric extends MIDlet {

    public void startApp() {
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}
Remember the Constructor?
package com.thinkit2ru;

import javax.microedition.midlet.*;

public class Metric extends MIDlet {

    public Metric() {          The Contructor:
    }                          Build Components Here
    public void startApp() {
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}
You need to Know...

•   Primitive data types
•   String Manipulation
•   Control Statements
•   Arrays and other data structures
•   GUI Design
•   Database Connectivity
•   Multithreading
•   Ethics and Conventions
Questions Please...
System.out.println(“Thank You”);
Ad

Recommended

Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Sagar Verma
 
Presentation on java
Presentation on java
shashi shekhar
 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Sagar Verma
 
Core java complete ppt(note)
Core java complete ppt(note)
arvind pandey
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Sagar Verma
 
Access modifiers
Access modifiers
Kasun Ranga Wijeweera
 
Introduction to java and oop
Introduction to java and oop
baabtra.com - No. 1 supplier of quality freshers
 
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Sagar Verma
 
Core Java Tutorial
Core Java Tutorial
eMexo Technologies
 
Core java
Core java
kasaragaddaslide
 
Core java
Core java
Ravi varma
 
Java Tutorial
Java Tutorial
Singsys Pte Ltd
 
1_JavIntro
1_JavIntro
SARJERAO Sarju
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Sagar Verma
 
Java tutorials
Java tutorials
น้องน๊อต อยากเหยียบดวงจันทร์
 
Java tutorials
Java tutorials
saryu2011
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Soumen Santra
 
Java 201 Intro to Test Driven Development in Java
Java 201 Intro to Test Driven Development in Java
agorolabs
 
Java 101 Intro to Java Programming
Java 101 Intro to Java Programming
agorolabs
 
Basic java for Android Developer
Basic java for Android Developer
Nattapong Tonprasert
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.
Tarunsingh198
 
Java for the Beginners
Java for the Beginners
Biswadip Goswami
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course
Kernel Training
 
New Features Of JDK 7
New Features Of JDK 7
Deniz Oguz
 
Core java Basics
Core java Basics
RAMU KOLLI
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
Hitesh-Java
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
Introduction to java 101
Introduction to java 101
kankemwa Ishaku
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
Java Programming Fundamentals: Complete Guide for Beginners
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 

More Related Content

What's hot (20)

Core Java Tutorial
Core Java Tutorial
eMexo Technologies
 
Core java
Core java
kasaragaddaslide
 
Core java
Core java
Ravi varma
 
Java Tutorial
Java Tutorial
Singsys Pte Ltd
 
1_JavIntro
1_JavIntro
SARJERAO Sarju
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Sagar Verma
 
Java tutorials
Java tutorials
น้องน๊อต อยากเหยียบดวงจันทร์
 
Java tutorials
Java tutorials
saryu2011
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Soumen Santra
 
Java 201 Intro to Test Driven Development in Java
Java 201 Intro to Test Driven Development in Java
agorolabs
 
Java 101 Intro to Java Programming
Java 101 Intro to Java Programming
agorolabs
 
Basic java for Android Developer
Basic java for Android Developer
Nattapong Tonprasert
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.
Tarunsingh198
 
Java for the Beginners
Java for the Beginners
Biswadip Goswami
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course
Kernel Training
 
New Features Of JDK 7
New Features Of JDK 7
Deniz Oguz
 
Core java Basics
Core java Basics
RAMU KOLLI
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
Hitesh-Java
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
Introduction to java 101
Introduction to java 101
kankemwa Ishaku
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Sagar Verma
 
Java tutorials
Java tutorials
saryu2011
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Soumen Santra
 
Java 201 Intro to Test Driven Development in Java
Java 201 Intro to Test Driven Development in Java
agorolabs
 
Java 101 Intro to Java Programming
Java 101 Intro to Java Programming
agorolabs
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.
Tarunsingh198
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course
Kernel Training
 
New Features Of JDK 7
New Features Of JDK 7
Deniz Oguz
 
Core java Basics
Core java Basics
RAMU KOLLI
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
Hitesh-Java
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 
Introduction to java 101
Introduction to java 101
kankemwa Ishaku
 

Similar to Java Programming and J2ME: The Basics (20)

2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
Java Programming Fundamentals: Complete Guide for Beginners
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
oop unit1.pptx
oop unit1.pptx
sureshkumara29
 
CS8392 OOP
CS8392 OOP
DhanalakshmiVelusamy1
 
1 java programming- introduction
1 java programming- introduction
jyoti_lakhani
 
Java For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Pj01 2-install java and write first java program
Pj01 2-install java and write first java program
SasidharaRaoMarrapu
 
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
Module 1.pptx
Module 1.pptx
YakaviBalakrishnan
 
Introduction to java
Introduction to java
Java Lover
 
object oriented programming unit one ppt
object oriented programming unit one ppt
isiagnel2
 
ITFT - Java Coding
ITFT - Java Coding
Blossom Sood
 
Java introduction
Java introduction
The icfai university jaipur
 
JavaClassPresentation
JavaClassPresentation
juliasceasor
 
Letest
Letest
Prakash Poudel
 
Java Programming concept
Java Programming concept
Prakash Poudel
 
02 basic java programming and operators
02 basic java programming and operators
Danairat Thanabodithammachari
 
Java Programming
Java Programming
Anjan Mahanta
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2
Uday Sharma
 
Object Oriented Programming-JAVA
Object Oriented Programming-JAVA
Home
 
2. Introduction to Java for engineering stud
2. Introduction to Java for engineering stud
vyshukodumuri
 
Java Programming Fundamentals: Complete Guide for Beginners
Java Programming Fundamentals: Complete Guide for Beginners
Taranath Jaishy
 
1 java programming- introduction
1 java programming- introduction
jyoti_lakhani
 
Java For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
Pj01 2-install java and write first java program
Pj01 2-install java and write first java program
SasidharaRaoMarrapu
 
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
Java UNITbgbgbfdbv v bbfbf cvbgfbvc gf 1.pptx
hofon47654
 
Introduction to java
Introduction to java
Java Lover
 
object oriented programming unit one ppt
object oriented programming unit one ppt
isiagnel2
 
ITFT - Java Coding
ITFT - Java Coding
Blossom Sood
 
JavaClassPresentation
JavaClassPresentation
juliasceasor
 
Java Programming concept
Java Programming concept
Prakash Poudel
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2
Uday Sharma
 
Object Oriented Programming-JAVA
Object Oriented Programming-JAVA
Home
 
Ad

Recently uploaded (20)

Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
RAKESH SAJJAN
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
RAKESH SAJJAN
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
RAKESH SAJJAN
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
RAKESH SAJJAN
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
Ad

Java Programming and J2ME: The Basics

  • 1. Mobile Programming with J2ME By Oluwatosin Adesanya
  • 2. Lesson 01: Basic Java Programming
  • 3. Java is ... • A Pure OOP Language • A Hybrid Programming Language • First Compiled and Interpreted • Runs on a JVM (Java Virtual Machine) Byte Code Source Object Code Code
  • 4. Getting Started • JDK (Java Development Kit) • Editor (Notepad) OR ... • Integrated Development Environment (Netbeans, Eclipse, JCreator etc.)
  • 5. Setting Up Java • Install the JDK • The JDK Sits in C:Program FilesJavajdk1.6.0 • Set the PATH Environmental Variable (How?)
  • 6. Setting the PATH Environmental Variable Open your Systems Property: choose Advanced System Settings, Click the Environmental Variable Button on the Dialog that shows Up
  • 7. Setting the PATH Environmental Variable Scroll and Select Path , Click Edit Button
  • 8. Setting the PATH Environmental Variable Append the current path with the path to the Java bin folder
  • 9. Running Java • Save your Java source code as a .java file • Use the javac Command to compile your source codes (.java files) e.g javac Result.java • A .class file is generated called a bytecode • Use java Command to run the .class file e.g java Result • Do not add .class when compiling Source Object javac Byte Code java Code Code
  • 10. The Structure of a Java Program • Java Programs are made up of classes • Classes are made up of methods • Java existing (ready-made) classes are found in the Java Class Libraries (Also Called Java APIs) • Execution of Java programs begin at the main method
  • 11. A Simple Java Program public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }
  • 12. Classes and Objects • A Class is like a factory from which Objects are churned Out. Example Class Car could produce objects Volkswagen bettles, Toyota Camri, Peugeout 306 An Object is a model of the Real World and has States (Or Properties) and Behaviours (Or Actions) Example Object Car States are Color, Speed, Size, Plate Licence No, Cost Behaviours are Start, Stop, Accelerate, Fuel, Open Door, etc.
  • 13. Creating a Class Use the class Keyword Example public class HelloWorld { . . . } Do NOT Forget! Name your java file ClassName.java
  • 14. Adding States (Properties) • States in Java are simply variables (Otherwise called fields) Example public class PaySlip { int numdone; String name; } Observe?! Every Line of Java code ends with a semicolon (;) int,float, double, boolean, char … are Java Primitive Types
  • 15. Adding Behaviours (Methods) • Methods are functions that control states or fields or variables. They change the state of an object. Example public class PaySlip { int numdone; String name; public double getPay() { return 40.00 * numdone; } Method getPay() } Guess What? We already have a working Java Class!
  • 16. Using Our Class PaySlip We implement another tester class which contains the main method. public class TestPaySlip { public static void main(String[] args){ PaySlip opay=new PaySlip(); System.out.println("n"+opay.getPay()); } }
  • 17. Constructors • Initializes the Object after memory allocation • Takes the same name as the Class • May accept parameters OR... may not • Every Class has a default constructor that accepts no parameter • Has No Return Type • Can be Overloaded (there can be multiple Constructors)
  • 18. Constructors public class PaySlip { int numdone; String name; public PaySlip(int numdone, String name) { this.numdone=numdone; this.name=name; } public PaySlip(){ name=“Nobody”; numdone=0; } public double getPay() { return 40.00 * numdone; } }
  • 20. Lesson 02: Java 2 Micro Edition(J2ME)
  • 21. J2ME is ... • Java for small devices • Divided into Configurations, Profiles and Optional APIs Configurations, Profiles and Optional APIs combined together make up a stack Configurations: Specifies a JVM. We have CDC and CLDC CLDC (Connected Limited Device Configuration) is designed for devices with limited memory, displays, battery power and inputs. Profiles: Layered on top of CLDC and adds APIs for specific devices. We have MIDP, PDAP and Personal Profiles MIDP (Mobile Information Device Profile) has characteristics that makes most low end phones and PDAs fit in. J2ME is covered by MIDPs
  • 23. MIDP Apps are ... • Called MIDlets • Portable • Secured • represented by instances of javax.microedition.midlet.MIDlet class • Distributed as JAR (Java Archive) files along with a MANIFEST file and an Application Descriptor File (.jad file) • Reduced to small sizes before distribution by an Obfuscator Popular J2ME Apps: Opera Mini, 2go, Go Bible
  • 25. Shall We Create a MIDlet? package com.thinkit2ru; import javax.microedition.midlet.*; public class Metric extends MIDlet { public void startApp() { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
  • 26. Remember the Constructor? package com.thinkit2ru; import javax.microedition.midlet.*; public class Metric extends MIDlet { public Metric() { The Contructor: } Build Components Here public void startApp() { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
  • 27. You need to Know... • Primitive data types • String Manipulation • Control Statements • Arrays and other data structures • GUI Design • Database Connectivity • Multithreading • Ethics and Conventions