Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
C++ Basics Variables, Identifiers, Assignments, Input/Output.
Objective: Dealing with data in C++ Agenda: Notes Essay Help.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
CMT Programming Software Applications
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 Wanda M. Kunkle.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Java Building Elements Lecture 2 Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
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.
Primitive Data Types and Operations Identifiers, Variables, and Constants Primitive Data Types Byte, short, int, long, float, double, char, boolean Casting.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
Primitive Variables.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Java Programming: From Problem Analysis to Program Design, 5e Chapter 2 Basic Elements of Java.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Primitive Variables.
A variable is a storage location for some type of value. days 102 taxrate 7.75 int days = 102; double taxrate = 7.75; char grade = ‘A’; boolean done.
Chapter 2 Variables.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
1 Week 5 l Primitive Data types l Assignment l Expressions l Documentation & Style Primitive Types, Assignments, and Expressions.
1.2 Primitive Data Types and Variables
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Java – Variables and Constants By: Dan Lunney. Declaring Variables All variables must be declared before they can be used A declaration takes the form:
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
1 2. Program Construction in Java. 01 Java basics.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Review by Mr. Maasz, Summary of Chapter 2: Starting Out with Java.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
Topic 2 Elementary Programming
Chapter 2 Variables.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Crash course in the Java Programming Language
Elementary Programming
Chapter 2 Elementary Programming
Documentation Need to have documentation in all programs
Data types and variables
Java Programming: From Problem Analysis to Program Design, 4e
Chapter 2.
Principles of Computer Programming (using Java) Chapter 2, Part 1
Unit-2 Objects and Classes
Computers & Programming Languages
Chapter 2 Edited by JJ Shepherd
Chapter 2: Basic Elements of Java
Chapter 2 Variables.
Recap Week 2 and 3.
Java Programming Review 1
Chap 2. Identifiers, Keywords, and Types
Chapter 2 Variables.
Chapter 2 Primitive Data Types and Operations
Variables and Constants
Review of Java Fundamentals
Presentation transcript:

Java Syntax Part I Comments Identifiers Primitive Data Types Assignment

Java Syntax - Comments Type 1: –begins with /* –continues till the next */ Type 2: –begins with // –continues till the end of the line Type 3: –begins with /**, and continues till the next */

Java Syntax -- comments (style) Good programming practice –Put helpful comments at the beginning of a big block on the same line of certain statements –Good internal documentation is very important

Java Syntax -- comments (example) // // withdraw: withdraw money from banking_account // Input : amount = the amount of money to withdraw // void withdraw(float amount) { // if not enough money in the account ---- … // else, we have enough money in the account }

Java Syntax -- Identifiers Names of declared entities –variables, constans, labels… Must start with a letter: [A..Z][a..z] –including _ (underscore) or $ (dollar sign) Followed by letters or digits Java language keywords can not be used as identifiers.

Java Syntax -- Identifiers (example) accountNumber length1 length_2

Java Syntax -- Primitive Data Types boolean: takes only 2 values true or false Example: boolean done = false; char : contains a character Example: char ch; byte, short, int and long : Integral Types Example: int num = 3; float, double : Floating-Point Types Example: float temperature = 37.6;

Java Syntax -- Assignment Example using integers: int i = 2; // create an integer variable i = 5; // change i to 5 int j = 6; // create an integer variable j i = j*3 // multifply the value of j by 3 // now i = 18 i = i + 4; // NOT AN EQUATION! // i was 18, i+4=22; new i=22. Calculate the value on the RIGHT HAND SIDE Assign the result to the variable on the LEFT HAND SIDE

Java Syntax -- Assignment (Abbreviations) Examples: j = j + 1; // as before j += 1; // same as j = j + 1; j += 5; // same as j = j + 5; j++; // same as j = j + 1;