Basic Java Programming Teguh Sutanto, M.Kom.. Tujuan Mahasiswa dapat menyebutkan berbagai tipe data dan operato.

Slides:



Advertisements
Similar presentations
Introducing C++ Elements. CSCE 1062 Outline Main algorithms’ constructs General form of a C++ program {section 2.5} C++ language elements {section 2.1}
Advertisements

JAVA Variables Declaring Variables Over writing Variables Data types Displaying contents of a Variable Naming a Variable Strings.
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
1 pritisajja.info Unlocking the World of Java Programming….. Priti Srinivas Sajja February, 2014 Visit pritisajja.info for detail Future Technology for.
L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Variabel, Tipe Data & Operator Teguh Sutanto, M.Kom.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Object Oriented Programming in JAVA
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
ECE122 L2: Program Development February 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 2 Program Development.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 Data types, operations, and expressions Overview l Format of a Java Application l Primitive Data Types l Variable Declaration l Arithmetic Operations.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Hello, world! Dissect HelloWorld.java Compile it Run it.
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
Pert II: Basic Java Programming Teguh Sutanto, M.Kom.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
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.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Lecture #5 Introduction to C++
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Copyright Curt Hill Variables What are they? Why do we need them?
VARIABLES AND DATA TYPES Chapter2:part1 1. Objectives: By the end of this section you should: Understand what the variables are and why they are used.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
© A+ Computer Science - A reference variable stores the memory address of an object. Monster fred = new Monster(); Monster sally.
CPS120: Introduction to Computer Science Variables and Constants.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Console Output, Variables, Literals, and Introduction to Type
Data types and variables
Programming Language Concepts (CIS 635)
Introduction to the C Language
An Introduction to Java – Part I, language basics
Basics of ‘C’.
C++ Data Types Data Type
Chapter 2: Java Fundamentals
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
The Data Element.
The Data Element.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
JAVA. Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of platforms, such.
Presentation transcript:

Basic Java Programming Teguh Sutanto, M.Kom.

Tujuan Mahasiswa dapat menyebutkan berbagai tipe data dan operato

Materi Struktur dasar program Java Variable Constanta Tipe Data Operator

Buku Referensi

A computer program A computer program or application is a set of instructions, written in a programming language that enables a computer to perform some specifi ed task

Mengapa Java? Java is small and beautiful Java is object oriented Java supports the Internet Java is general purpose Java is platform independent Java has libraries

Struktur Program Java Nama Class (Nama Program) Isi program “{ }” Method main(String []argz) Local variable

Penamaan Program/Class Kata Benda Diawali dengan HurufBesar Nama File = NamaProgram Contoh: public class ProgramPertamax disimpan dengan nama ProgramPertamax.java Tidak boleh ada spasi Contoh: Program Pertamax Tidak boleh diawali dengan angka Contoh: 1Program

Method public static void main(String []param) public static void main(String []param){ //code program //alur program } Parameter Program Every Java application contains a class with a main method. When the application starts, the instructions in the main method are executed. Setiap program yang akan dijalankan oleh JVM harus ada method launcher yang dengan nama main(String[] a)

dengan nama PrgPertamax.java >javac PrgPertamax.java >java PrgPertamax

A keyword is a dictionary word — a word that’s built right into a language

Keywoards abstractcontinuefornew switchassertdefaultgoto packagedosynchronizedboolean ifprivatethisbreak doubleimplementsprotectedthrow byteelseimportpublic throwscaseenuminstanceof returntransientcatchextends intshorttrychar finalinterfacestaticvoid classfinallylongstrictfp volatileconstfloatnative superwhilese

Alur Program 1.sequences 2.repetitions 3.selections 4.methods 5.ready-made objects 6.objects you write yourself

Case Sensitive The java proGRAMMing lanGUage is case-sensitive. ThIS MEans that if you change a lowerCASE LETTer in a wORD TO AN UPPercase letter, you chANge the wORD’S MEaning. ChangiNG CASE CAN MakE the enTIRE WORD GO FROM BeiNG MEANINGFul to bEING MEaningless.

public static void main(String args[]) { System.out.println(“Chocolate, royalties, sleep”); } main: The main starting point for execution in every Java program. String: A bunch of text; a row of characters, one after another. System: A canned program in the Java API. (This program accesses some features of your computer that are outside the direct control of the Java virtual machine (JVM).) out: The place where a text-based program displays its text. (For a program running in Eclipse, the word out represents the Console view. println: Display text on your computer screen

Variable: The Holders of Information Sebuah tempat untuk menyimpan data, contoh: Angka 365 merepresentasikan jumlah hari dalam satu tahun Angka 37 derajat celcius menunjukkan suhu normal tubuh manusia Nama seorang aktor favorit, Jet Lee

Variable di mata seorang programer JumlahHari suhuTubuh aktorFavorit Programmer Variables in algebra are letters of the alphabet, like x and y, but in computer languages, they can also be any descriptive names like sum, answer, or first_value.

A variable is a named memory location capable of storing data of a specified type

So…what is the var? Computer programs manipulate (or process) data. A variable is used to store a piece of data for processing. It is called variable because you can change the value stored. More precisely, a variable is a named storage location, that stores a value of a particular data type. In other words, a variable has a name, a type and stores a value. A variable has a name (or identifier), e.g., radius, area, age, height. The name is needed to uniquely identify each variable, so as to assign a value to the variable (e.g., radius=1.2), and retrieve the value stored (e.g., radius*radius*3.1416).

Variable…(cont) A variable has a type. Examples of type are: int: for integers (whole numbers) such as 123 and -456; double: for floating-point or real numbers, such as , , having an optional decimal point and fractional part; String: for texts such as "Hello", "Good Morning!". Text strings are enclosed within a pair of double quotes.

byte short int long Integers float double. Floating-point This group includes char, which represents symbols in a character set, like letters and numbers. Characters This group includes boolean, which is a special type for representing true/false values. Boolean

Deklarasi Variable A variable must be declared before it can be used. A variable declaration specifi es the type of data that the variable can hold, for example int or double, and the name of the variable. varType varName; // Declare a variable of a type varType varName1, varName2,...; // Declare multiple variables of the same type varType varName = initialValue; // Declare a variable of a type, and assign an initial value varType varName1 = initialValue1, varName2 = initialValue2,... ; // Declare variables with initial values

A variable can store a value of that particular type. It is important to take note that a variable in most programming languages is associated with a type, and can only store value of the particular type. For example, a int variable can store an integer value such as 123, but NOT real number such as 12.34, nor texts such as "Hello". The concept of type was introduced into the early programming languages to simplify intrepretation of data made up of 0s and 1s.

Contoh Variable

Pembahasan