Синтаксис языка Java.

Slides:



Advertisements
Similar presentations
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
Advertisements

Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
5/17/ Programming Constructs... There are several types of programming constructs in JAVA. - If-else construct or ternary operator - while - do-while.
Особенности Java. Блок static static { } Создание и уничтожение объектов  new – создание объекта  finalyze()
Язык JavaScript Скриптовый язык для выполнения на html-страницах.
Новосибирск, 2004 (С) Всеволод Рылов, все права защищены 1 Основы программирования на языке Java Алгоритмические средства Java.
PHP как язык программирования. Типы данных логические величины int, integer – целые числа real, double, float – вещественные числа string – строки array.
BASIC JAVA. Hello World n // Hello world program public class MyFirstJavaProgram { public static void main(String args[]) { char c = 'H'; String s =
Язык Java. JSP..
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
1 Учебный курс Введение в JavaScript и CGI Лекция 4 Работа с графикой, гипертекстовые переходы и синтаксис языка кандидат технических наук Павел Брониславович.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Chapter 2: Everything is an Object ● C++ has many non object oriented features inherited from C. It is a hybrid language meaning that it support different.
Control Structures if else do while continue break switch case return for.
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
2: Everything is an Object You Manipulate Objects Using References Primitives Arrays in Java Scoping You Never Destroy Objects Creating New Data Types:
Язык программирования C#
Objects, Classes and Syntax Dr. Andrew Wallace PhD BEng(hons) EurIng
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Mixing integer and floating point numbers in an arithmetic operation.
1 CSC 201: Computer Programming I Lecture 2 B. S. Afolabi.
Основы языка. 1.Переменные 2.Операторы 3.Примитивные типы 4.Массивы 5.Выражения 6.Блоки 7.Управление циклами.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Everything is an object (CH-2) Manipulating Objects with References. Manipulating Objects with References. String s; String s = “IS2550” String s = new.
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 45 – 90 seconds per question. Determine the output.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
Chapter One Lesson Three DATA TYPES ©
CSCI S-1 Section 4. Deadlines for Homework 2 Problems 1-8 in Parts C and D – Friday, July 3, 17:00 EST Parts E and F – Tuesday, July 7, 17:00 EST.
Java Part I By Wen Fei, HAO. Program Structure public class ClassName { public static void main(String[] args) { program statements } user defined methods.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Object-Oriented Programming Fundamentals. Comp 241, Fall Example Colored points on the screen What data goes into making one? Coordinates Color.
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
Java Scanner Class Keyboard Class. User Interaction So far when we created a program there was no human interaction Our programs just simply showed one.
Output Programs These slides will present a variety of small programs. Each program has a compound condition which uses the Boolean Logic that was introduced.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
WAP to find out the number is prime or not Import java.util.*; Class Prime { public static void main(string args[]) { int n,I,res; boolean flag=true;
JAVA METHODS (FUNCTIONS). Why are they called methods? Java is a strictly object-oriented programming language Methods are functions inside of objects.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Object Oriented Programming Lecture 2: BallWorld.
Лекции марта 2016 г.. оператор объявления переменных : int a; char a, b = 5, c; присваивание ( Assign ): id = ; пустой оператор ; if( ) else.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
JavaScript
Introduction of Java Fikri Fadlillah, S.T.
Быстрое введение в язык C++
Lecture 2: Data Types, Variables, Operators, and Expressions
Function Call Trace public class Newton {
An Introduction to Java – Part I
Chapter 2.
Computing Adjusted Quiz Total Score
Unit-2 Objects and Classes
null, true, and false are also reserved.
Introduction to Java Programming
An Introduction to Java – Part I, language basics
Arrays of Objects Fall 2012 CS2302: Programming Principles.
Java so far Week 7.
Propositional Equivalences Rosen 5th and 6th Editions section 1.2
Arrays of Objects Fall 2012 CS2302: Programming Principles.
Recursive GCD Demo public class Euclid {
Default Arguments.
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
JAVA An Introduction to Java OOP Basics
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Names of variables, functions, classes
Introduction to java Part I By Shenglan Zhang.
More on iterations using
Presentation transcript:

Синтаксис языка Java

Символы и синтаксис Перевод строчки эквивалентен пробелу Регистр в именах различается

Комментарии // Комментарии до конца строки /* Многострочные комментарии */

Типы данных Примитивные типы данных: Объекты: boolean char – 2 байта byte – 1 байт: целое -128 ÷ 127 short – 2 байта: целое -215 ÷ 215 -1 int – 4 байта: целое -231 ÷ 231 -1 long – 8 байт: целое -263 ÷ 263 -1 float – 4 байта double – 8 байт void Объекты: Переменные – ссылки на объекты

Определение новых типов данных class имя_класса { тело_класса } тело_класса – объявления полей и методов класса Поля: данные любого типа (ссылки!) Методы: возвращаемый_тип имя_метода(аргументы) { тело возвращение значения – return значение

Переменные Объявления переменных: Создание объекта: Поля объекта: тип имя_переменной; тип имя_переменной = значение; Объявление не создаёт экземпляра объекта! Создание объекта: имя_переменной = new тип(аргументы); - вызов конструктора Поля объекта: имя_переменной.имя_поля

Директивы импортирования import пакет.класс; import пакет.*;

Операторы (инструкции) Присваивание x=1; Условный оператор if( условие ) оператор; if( условие ) оператор1; else оператор2; Циклы: for(инициализация;условие;шаг) тело; while( условие ) тело;

Пример программы // HelloDate.java import java.util.*; public class HelloDate { public static void main(String[] args) { System.out.println("Hello, it's: "); System.out.println(new Date()); }