Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.

Slides:



Advertisements
Similar presentations
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
Advertisements

Introduction to Java Programming
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Chapter 2: Java Fundamentals Java Program Structure.
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
IB Computer Science II Paul Bui
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
“Introduction to Programming With Java”
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
CS107 Introduction to Computer Science Java Basics.
1 CSC 201: Computer Programming I B. S. Afolabi. Introduction  3 unit course  2 hours of lecture/week Thursdays 4.00pm – 6.00pm Mondays 4.00pm – 6.00pm.
Welcome to the Lecture Series on “Introduction to Programming With Java”
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
FRST JAVA PROGRAM. Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Spring PImage Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Programming Concept Chapter I Introduction to Java Programming.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Java - Classes JPatterson. What is a class? public class _Alpha { public static void main(String [] args) { } You have been using classes all year – you.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
A Look at Java. Categorize Java Which paradigm? Which paradigm? Scripting? Scripting? Declarative or procedural? Declarative or procedural? Which generation?
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
CSI 3125, Preliminaries, page 1 Compiling the Program.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
introductory lecture on java programming
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.3 Write Your First Java Program Produced by Harvey.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
Methods.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
CS 177 Recitation Week 1 – Intro to Java. Questions?
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Machine Language Computer languages cannot be directly interpreted by the computer – they are not in binary. All commands need to be translated into binary.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
Introduction to programming in java
CS210 Intermediate Computing with Data Structures (Java)
Lecture 1b- Introduction
Object-Oriented programming for Beginners LEAPS Computing 2015
The need for Programming Languages
Content Programming Overview The JVM A brief look at Structure
Introduction to.
Programming Language Concepts (CIS 635)
CSC 113 Tutorial QUIZ I.
An Introduction to Java – Part I, language basics
Hands-on Introduction to JAVA
Object Oriented Programming in java
Java Intro.
CS 180 Assignment 6 Arrays.
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
COM-152: Computer Programming Types, Variables, Operators Part 1 of 2
IB Computer Science II Paul Bui
Chapter 2: Java Fundamentals
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

Introduction to java (class and object)

Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand it Java –“Most popular” language –Runs on a “virtual machine” (JVM) –More complex than some (eg. Python) –Simpler than others (eg. C++)

First Program class Hello { public static void main(String[] arguments) { // Program execution begins here System.out.println("Hello world."); }

How to run?

Create the path information file: –Open txt file –Use the command set to refer to: Java home Bin file –Save the file name.bat Run a command DOS windows Run the path file first Use the command javac to compile your java file Use the command java to execute your.class file Can you see any out put? set JAVA_HOME=C:\jdk set PATH=%PATH%;c:\jdk\bin;

Java code structure class CLASSNAME { public static void main(String[] arguments) { STATEMENTS }

Can you write a program to print a student card. Name: Mohamed Elshaikh School : Computer ID: Job: Student

Assignment Used to give values to the variables. Example: Name= ali; class Hello3 { public static void main(String[] arguments) { String name = “Mohamed elshaikh"; String school=“ computer”; String job=“student”; Int id=123432; System.out.println(“Name :”+name); System.out.println(“ School :”+school); System.out.println(“ID :”+id); System.out.println(“ Job :”+job); }

Card example as a class Attributes –Name –School –Id Methods –Print the card –Get the name

Card in java Create the class –Create the instructor –Declare the attributes –Declare the methods The object –A new variable for the class type –Created by the constructor –Can use the methods –Created in the program body

Lets cod it public class Card { // the Card class has three fields public String name; public String school; public int id; public String job; // the Card class has one constructor public Card(String n,String s,String j,int i) { name = n; school =s; job = j; id = i; } // the Card class has three methods public void setName(String s) { name = s; } public String getName() { return name; } public void printCard() { System.out.println("Name :"+name); System.out.println("School :"+school); System.out.println("ID :"+id); System.out.println("Job :"+job); }