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

Similar documents
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Introduction to Programming (Java) 2/12

JAVA Programming Fundamentals

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

CSC 1214: Object-Oriented Programming

3. Java - Language Constructs I

Introduction to Programming Using Java (98-388)

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

An overview of Java, Data types and variables

Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003

A Java program contains at least one class definition.

Chapter 2: Data and Expressions

Java Overview An introduction to the Java Programming Language

Getting started with Java

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

JAC444 - Lecture 1. Introduction to Java Programming Language Segment 4. Jordan Anastasiade Java Programming Language Course

CS313D: ADVANCED PROGRAMMING LANGUAGE

Chapter 2: Using Data

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

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal

Chapter 2: Data and Expressions

PROGRAMMING FUNDAMENTALS

Lecture 3. More About C

Basic Operations jgrasp debugger Writing Programs & Checkstyle

Operators and Expressions

Language Fundamentals Summary

Visual C# Instructor s Manual Table of Contents

Chapter 02: Using Data

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

CPSC 319. Week 2 Java Basics. Xiaoyang Liu & Sorting Algorithms

The Arithmetic Operators

Chapter 2: Using Data

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

UNIT- 3 Introduction to C++

Java Basic Programming Constructs

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

Chapter 2: Using Data

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure

Java Notes. 10th ICSE. Saravanan Ganesh

4 Programming Fundamentals. Introduction to Programming 1 1

Lec 3. Compilers, Debugging, Hello World, and Variables

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

Chapter 2: Data and Expressions

Java Programming. Atul Prakash

Operators. Java operators are classified into three categories:

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

JAVA OPERATORS GENERAL

CSC 1107: Structured Programming

Course information. Petr Hnětynka 2/2 Zk/Z

Operators in java Operator operands.

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Basics of Java Programming

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

Declaration and Memory

Zheng-Liang Lu Java Programming 45 / 79

Programming. Syntax and Semantics

1 Shyam sir JAVA Notes

Informatics Ingeniería en Electrónica y Automática Industrial

A variable is a name that represents a value. For

6.096 Introduction to C++ January (IAP) 2009

SECTION II: LANGUAGE BASICS

Values and Variables 1 / 30

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Chapter 3: Operators, Expressions and Type Conversion

A variable is a name for a location in memory A variable must be declared

Course information. Petr Hnětynka 2/2 Zk/Z

CMPT 125: Lecture 3 Data and Expressions

CS 61C: Great Ideas in Computer Architecture Introduction to C

The Warhol Language Reference Manual

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

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

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

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

Lecture Notes. System.out.println( Circle radius: + radius + area: + area); radius radius area area value

Expressions & Flow Control

SOFTWARE DEVELOPMENT 1. Operators 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

Chapter 2 Elementary Programming

Decaf Language Reference Manual

Course Outline. Introduction to java

Accelerating Information Technology Innovation

CSC Java Programming, Fall Java Data Types and Control Constructs

Chapter 2 Primitive Data Types and Operations

Java Bytecode (binary file)

Program Fundamentals

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

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

Primitive Data Types: Intro

Java Programming Fundamentals. Visit for more.

Types and Expressions. Chapter 3

Introduction to C Language

Java Primer 1: Types, Classes and Operators

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

Fundamental of C programming. - Ompal Singh

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

More Programming Constructs -- Introduction

Transcription:

Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code, slows down compilation, disables -depend. The Java Interpreter java [ options ] classname args The Java Debugger jdb [ options ] Type help or? to get started. On windows we have Jcreator and netbeans on our BSD systems. (We also have netbeans on windows available, but it is not nearly as quick as jcreator.) 1

The simplest program: public class Hello public static void main(string[] args) System.out.println("Hello."); Hello.java Executing this program would print to the console the sentence Hello.. A bit more complex: public class Second public static void main(string[] input) for (int i = input.length - 1; i >= 0; i--) System.out.print(input[i] + " "); System.out.print("\n"); Second.java Executing this program would print to the console the arguments in reverse order, each separated by one blank space.

Primitive data types : byte : 8 bit integer, [-128, 127] char : 16 bit unsigned integer, [0, 65536]. This character set offers 65536 distincts Unicode characters. short : 16 bit signed integer, [-32768, 32767] int : 32-bit integer, [-2147483648, 2147483647] long : 64 bit signed integer, [-9223372036854775807, 9223372036854775806] float : 32-bit float, 1.4023984e 45 to 3.40282347e+38 double : 64-bit float, 4.94065645841246544e 324 to 1.79769313486231570e+308 boolean : such a variable can take on one of two values, true or false. null : special case...

Symbol Description Punctuation : = assignment +, + = addition and string concatenation, = substraction, = multiplication /, / = division %, % = modulo ++ pre and post increment pre and post decrement == comparison, equality! boolean not > comparison, greater than < comparison, smaller than <= comparison, lesser-or-equal than >= comparison, greater-or-equal than! = comparison, not-equal && boolean AND boolean OR bitwise negation & bitwise AND bitwise OR ˆ bitwise xor <<, <<= shift left >>, >>= shift right character delimiter string delimiter ; statement terminator, separator () expression grouping. reference qualifier and decimal point /, / comment delimiter // single line comment

and there are a few more...

Operator Precedence : postfix ops prefix ops casting []. ( exp ) exp + + exp + + exp exp exp exp! exp ( type ) exp mult./div. / % add./sub. + shift << >> >>> comparison < <= > >= instanceof equality ==! = bitwise-and bitwise-xor & ˆ bitwise-or boolean and && boolean or conditional bool-exp? true-value : false-value assignment = op assignment + = = = / = % = bitwise assignment >>= <<= >>>= boolean assignment & = ˆ = =

Conditional executions : if ( exp ) statement else statement ex : if (input[i].equals("hello")) System.out.println("Hi!"); System.out.println("Beautiful day, isn t it?"); else System.out.println("Impolite.");? : simplification for assignments if (a < b) x = 5; else x = 25; can be rewritten x = a < b? 5 : 25;

switch ( exp ) case 1 : statement; break; case 2 : statement; case 3 : statement; break; default: statement; break; Escape characters : Escape Unicode Name Description \b \u0008 BS Backspace \t \u0009 HT Horizontal tab \n \u000a LF Line feed \ \u0022 Double quote \ \u0027 Single quote \\ \u005c \ Backslash

Iteration keywords : do statement while (exp); ex : int i = 0; do System.out.println(i++); while (i < 10); while (exp) statement ex : public static void main(string arg[]) throws IOException String temp, text = ""; BufferedReader input; input = new BufferedReader(new InputStreamReader(System.in)); while (! (temp = input.readline()).equals("end.")) text += temp; System.out.println(text); for (initial stms; exp; steps) statement ex : int j = 0; for (int i = 0; i < 10; i++) j += i; System.out.println(j);

Casting : Casting is used to force an explicit conversion of data from one type to another. Depending on what type of data is being cast to what other type, the actual conversion can take place either at run time or at execution time. If there is no way that the conversion could be valid, the compiler generates an error. ex: int i; float f; f = (float) i; /* however this is unnecessary since the compiler could have done the conversion automatically */ int a = 1, b = 2; float f; f = a / b; /* would return 0, since the calculation is done in int */ f = (float)a / (float) b; /* would return 1/2 */

Overloading : Commonly refers to the capability of an operator to perform differently depending on its context within a program. Although a few operators are already overloaded, Java does not allow you to change these. int a = 1, b = 2, c; c = a + b; /* c is now worth 3 */ String d = d, e = e, concat; concat = d + e; /* concat is now worth de */ However, as you ll see later on, we can overload methods.