Java Programming Language Mr.Rungrote Phonkam

Similar documents
Java Basic Datatypees

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

An overview of Java, Data types and variables

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Java Programming. Atul Prakash

Program Fundamentals

CSC 1214: Object-Oriented Programming

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Language Fundamentals Summary

3. Java - Language Constructs I

Building Java Programs. Introduction to Programming and Simple Java Programs

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Imports. Lexicon. Java/Lespérance 1. PROF. Y. LESPÉRANCE Dept. of Electrical Engineering & Computer Science

JAVA Ch. 4. Variables and Constants Lawrenceville Press

2 rd class Department of Programming. OOP with Java Programming

: Primitive data types Variables Operators if, if-else do-while, while, for. // // First Java Program. public class Hello {

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

Building Java Programs. Chapter 1: Introduction to Java Programming

Software Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS

Preview from Notesale.co.uk Page 9 of 108

Programming in C++ 4. The lexical basis of C++

Computer Components. Software{ User Programs. Operating System. Hardware

Welcome to CSE 142! Whitaker Brand. University of Washington, Winter 2018

Strings, Strings and characters, String class methods. JAVA Standard Edition

1.Which four options describe the correct default values for array elements of the types indicated?

Getting started with Java

Java Notes. 10th ICSE. Saravanan Ganesh

Software Practice 1 Basic Grammar

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

ECE 122 Engineering Problem Solving with Java

Computer Components. Software{ User Programs. Operating System. Hardware

COMP 202 Java in one week

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

CSC Java Programming, Fall Java Data Types and Control Constructs

Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

Week 6: Review. Java is Case Sensitive

Tony Valderrama, SIPB IAP 2009

PROGRAMMING FUNDAMENTALS

Java Identifiers, Data Types & Variables

Introduction to Java

A.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies

JOSE LUIS JUAREZ VIVEROS com) has a. non-transferable license to use this Student Guide

Getting started with Java

Lecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.

4 Programming Fundamentals. Introduction to Programming 1 1

JAVA Programming Fundamentals

6.096 Introduction to C++ January (IAP) 2009

TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN. Week 12/02/ /02/2007 Lecture Notes:

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

Chapter 2. Elementary Programming

The MaSH Programming Language At the Statements Level

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Introduction to C# Applications

JAVA OPERATORS GENERAL

CHAPTER 2 Java Fundamentals

Java Exceptions Java, winter semester

For the course, we will be using JCreator as the IDE (Integrated Development Environment).

3. Java - Language Constructs I

Tony Valderrama, SIPB IAP 2010

Object-Oriented Programming

Introduction to Programming Using Java (98-388)

Selenium Class 9 - Java Operators

DM503 Programming B. Peter Schneider-Kamp.

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

Java Programming Language Mr.Rungrote Phonkam

Darrell Bethea May 25, 2011

Points To Remember for SCJP

Accelerating Information Technology Innovation

CompSci 125 Lecture 02

The Java Language The Java Language Reference (2 nd ed.) is the defining document for the Java language. Most beginning programming students expect

MP 3 A Lexer for MiniJava

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

Java Programming Language. 0 A history

DM550 Introduction to Programming part 2. Jan Baumbach.

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

c) And last but not least, there are javadoc comments. See Weiss.

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

Java for Python Programmers. Comparison of Python and Java Constructs Reading: L&C, App B

Fundamentals of Programming. By Budditha Hettige

d. If a is false and b is false then the output is "ELSE" Answer?

Computer Programming, I. Laboratory Manual. Final Exam Solution

Static Methods & Decomposition

Language Features. 1. The primitive types int, double, and boolean are part of the AP

B.V. Patel Institute of BMC & IT, UTU 2014

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while

( &% class MyClass { }

1 Shyam sir JAVA Notes

Array. Prepared By - Rifat Shahriyar

The keyword list thus far: The Random class. Generating "Random" Numbers. Topic 16

NOOTAN PADIA ASSIST. PROF. MEFGI, RAJKOT.

A web-based IDE for Java

Transcription:

3 Java Programming Language Mr.Rungrote Phonkam rungrote@it.kmitl.ac.th

Contents 1. Identify 2. Method Member 3. Literals 4. Data Type 6. Variable

1. Identify ก ก Class, Data, Method, Variable, Label, ก ก ก ก ก ก _ $ age, name2, int2float, _name, Currency$ ก ก 65535 ก ก 101database, 2name ก ก ก ก Count, count CoUnT ก ก

ก ก ( ) ก 1. Identify abstract double int strictfp boolean else interface super break extends long switch byte final native synchronized case finally new this catch float package throw char for private throws class goto protected transient const if public try continue implements return void default import short volatile do instanceof static while

1. Identify ก ก ก ก ก ก ก ก MyClass, HelloJava, CollectedData ก ก ก ก color, name, height

1. Identify ก ก ( ) ก ก final ก ก ก ก ก SIZE, AMOUNT ก ก ก ก ก ก ก ก ก ก ก countmoney, openfile, setsize, print

1. Identify class SimpleClass { SimpleClass java SimpleClass Exception in thread "main" java.lang.nosuchmethoderror: main

2. Data Member Access_Level final static Data_Type Data_Name Access_Level ก package final ก ก static ก ก ก static Data_Type Data_Name ( ก ก )

2. Data Member ก (Access Level) Keyword public protected package* private Class Instance Extended_Class Extended_Instance Extended_Class Outer Package Extended_Instance Outer Package

2. Data Member class SimpleClass { int mydata; mydata SimpleClass java SimpleClass Exception in thread "main" java.lang.nosuchmethoderror: main

3. Method Member Access_Level final static Return_Type Method_Name ( Argument_List ) { Statements Access_Level ก final ก ก static ก ก ก static Return_Type ก Method_Name ( ก ก ) Argument_List ก Statements ( )

3. Method Member class SimpleClass { void mymethod( ) { mymethod SimpleClass java SimpleClass Exception in thread "main" java.lang.nosuchmethoderror: main

4. Literals ก 1, 46 7048 0 0 7 024 ก 248 30 0x 0X 0 9 ก a z ก A Z ก 0x1D 0X1d ก 29 1D16

4. Literals 12.4, 8.0, 9.33333 24E5 ก float ก F 3.0F ก ก 32 ก double ก D 3.0D ก ก 64 3.0F 3.0D ก ก ก ก ก 3.0F 32 3.0D 64 ก F D double

4. Literals ก ก ก ก (Single Quote) '4' ก 'A' ก '9' ก ก '+' ก ก ก

4. Literals ก ก ก (Double Quote) "Java", Hello! World", A", 9", ก "" ก ก NULL " " ก (Space Character) "A" ก A ก 'A'

4. Literals ก ก ก true false

4. Literals ก ก int i = 10 ; floatf=51.4 ; char ch = 'j' ; ก b == true ; status < 75 ; k=k+4 ;

5 Data Type (Primitive Data Type) C Language int, char, float, double,... (Reference Data Type) Instance / Object Array

5.1. Primitive Data Type ก byte, short, int long ก ก float double ก ก ก char ก ก boolean ก ก ก ก void

5.1. Primitive Data Type Keyword ( ) byte 8 0 short 16 0 int 32 0 long 64 0 float 32 0.0 double 64 0.0 char ก 16 boolean ก true/false false void - -

5.2. Reference Data Type ก ก ( ก ก ก ก ) Integer, StreamInput, Applet, Printer ก ก ก ก ก (Array) ( ก ก ก )

6Variables Class Variable Data Member (ก ก ) ก ก ก Data Data Member ก Method Variable กก ก ก Variable Parameter Variable ก ก ก ก ก Parameter

6.1. Class Variables Data Member ก ก Primitive Reference class Class_Name { Data_Member Data_Member... Data_Member ก Access_Level final static Primitive_Data_Type Data_Name

6.1. Class Variables class PublicStaticData { public static int a = 10; public static void main(string args[]) { System.out.println(a); a main PublicStaticData java PublicStaticData 10

ก ก ก 6.1. Class Variables System.out.print (Output) System.out.println (Output) ก System.err.print (Error) ก System.err.println (Error) ก

6.1. Class Variables System.out.print System.out.print( ) ( ก out ก ) System ( ก S) System ( ก ก ก )

ก 6.1. Class Variables System.out.println( Hello Java ) ก Hello Java System.out.println( Hello + Java ) ก Hello Java ก + ก Hello ก Java System.out.println(a) ก ก a a ก ก

ก 6.1. Class Variables \?? ก ก ก \n Linefeed \t Tab \r Carriage Retuen \f Formfeed \b Backspace \\ Backslash \' Single Quote \" Double Quote

Octal Escape Code 6.1. Class Variables \nnn nnn \0 \277 \377 Unicode Escape Code \uxxxx xxxx ก \u0041 ก A

6.1. Class Variables class TestFinalData { static final char c = J ; public static void main(string args[]) { System.out.println(a); c= a ;

6.1. Class Variables class PublicStaticData { public static int a = 10; class UseClass { public static void main(string args[]) { System.out.println(PublicStaticData.a); a PublicStaticData main UseClass Java UseClass 10

6.1. Class Variables class PublicStaticData { public int a = 10; class UseClass { public static void main(string args[]) { System.out.println(PublicStaticData.a); a PublicStaticData main UseClass

6.1. Class Variables Data Member ก ( ก ) Access_Level final static Class_Name Data_Name Data_Name = new Constructor_Name public final static Double mydouble; mydouble = new MyDouble(10.0); public final static Double mydouble = new MyDouble(10.0);

6.1. Class Variables class DefaultStaticRefData { static Double d = new Double(255.53); public static void main(string args[]) { System.out.println(d.toString()); d main DefaultStaticData Java DefaultStaticRefData 255.53

6.1. Class Variables class PublicStaticRefData { public static String s = Hello ; public static void main(string args[]) { System.out.println(s); s main PublicStaticData Java PublicStaticRefData Hello

6.2. Method Variables Primitive Reference class Class_Name { Method_Name() { Method Variable Method Variable... ก final Primitive_Data_Type Data_Name

6.2. Method Variables class PrimitiveVariable { public static void main(string args[]) { double d; d = 11.11; System.out.println(d); int a = 3500; System.out.println(a); a d main PublicStaticData java PrimitiveVariable 11.11 3500

Reference 6.2. Method Variables final Class_Name Data_Name = new Constructor()

6.2. Method Variables class RefClass { public int a = 10; class UseClass { public static void main(string args[]) { RefClass objdata = new RefClass (); System.out.println(objdata.a); java UseClass 10

6.2. Method Variables a RefClass a objdata.a objdata main UseClass

6.2. Method Variables class RefData { public static int a; class UseClass { public static void main(string args[]) { RefData obja = new RefData( ); RefData objb = new RefData( ); obja.a = 10; objb.a = 20; System.out.println(objA.a); System.out.println(objB.a); java UseClass 20 20

6.2. Method Variables a RefData a obja a main objb UseClass

6.3. Parameter Variables ก ก Primitive Reference Primitive ก ก ( Copy Value) Class Array ก (Reference Value)

6.3. Parameter Variables ก กก

6.3. Parameter Variables 5 ก 5 Copy Value

6.3. Parameter Variables class CopyParam { public static int computeadd(int a, int b) { return a + b; public static int computeminus(int a, int b) { return a - b; public static void main(string args[]) { int number1 = Integer.parseInt(args[0]); int number2 = Integer.parseInt(args[1]); System.out.println( Result of Your Number ); System.out.print( \t + number1 + + + number2 + = ); System.out.println(computeAdd(number1, number2)); System.out.print( \t + number1 + - + number2 + = ); System.out.println(computeMinus(number1, number2));

6.3. Parameter Variables java CopyParam 45 12 Result of Your Number 45 + 12 = 57 45-12 = 33

6.3. Parameter Variables 5 ก Reference Value

6.3. Parameter Variables class RefParam { public static int computemod(integer a, Integer b) { return a.intvalue( ) % b.intvalue( ); public static void main(string args[]) { Integer number1 = new Integer(args[0]); Integer number2 = new Integer(args[1]); System.out.print(number1 + Mod + number2 + = ); System.out.println( computemod(number1, number2));

6.3. Parameter Variables java RefParam 7 2 7Mod2=1 java RefParam 151 7 151 Mod 7 = 4

6.3. Parameter Variables class MyInt { int i; class ChangeDataInRefParam { public static void Abs1(MyInt a) { a.i = (a.i<0)? a.i * -1: a.i; public static int Abs2(MyInt a) { return ( (a.i<0)? a.i * -1: a.i ); public static void main(string args[]) { MyInt number1 = new MyInt(); number1.i = -55; MyInt number2 = new MyInt(); number2.i = -184; Abs1(number1); System.out.println("Abs1 " + number1.i); System.out.println("Abs2 " + Abs2(number2));

6.3. Parameter Variables java ChangeDataInRefParam Abs1 55 Abs2 184