Programi,Podaci,Varijable,Računanje - 1

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.
DATA TYPES, VARIABLES, ARITHMETIC. Variables A variable is a “named container” that holds a value. A name for a spot in the computer’s memory This value.
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.
Constants and Data Types Constants Data Types Reading for this class: L&L,
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
Primitives in Java Java has eight primitive types –boolean –integral types: signed: long, int, short, byte unsigned: char –floating point types: double,
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
1 Data types, operations, and expressions Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions.
Java Syntax Primitive data types Operators Control statements.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Introduction.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
String Escape Sequences
2015/8/221 Data Types & Operators Lecture from (Chapter 3,4)
Programming Principles Data types and Variables. Data types Variables are nothing but reserved memory locations to store values. This means that when.
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
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.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Primitive Data Types and Operations Identifiers, Variables, and Constants Primitive Data Types Byte, short, int, long, float, double, char, boolean Casting.
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.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
Primitive Variables.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
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.
Matlab Data types, input and output. Data types Char: >> a = ‘ Jim ’ Char: >> a = ‘ Jim ’ Numeric: uint8, uint16, uint32, uint64 int8, int16, int32, int64.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
1.2 Primitive Data Types and Variables
Primitive Data Types 1 In PowerPoint, point at the speaker icon, then click the "Play" button.
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 06 – Java Datatypes Webpage:
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
C is a high level language (HLL)
Data Types References:  Data Type:  In computer science and computer programming, a data type or simply type is a.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
1 Identifiers: Names of variables, functions, classes (all user defined objects), Examples: a b gcd GCD A COSC1373 TAX Tax_Rate Tax Rate if else while.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
Fundamentals 2.
Relational Operator and Operations
Chapter 2 Variables.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Chapter 6: Data Types Lectures # 10.
Data Types The type states how much and what kind of data the variable can store. integers- whole numbers no fractional parts int, short, long floating.
Java package classes Java package classes.
Chapter 2.
Programi,Podaci,Varijable,Računanje- Uvod
Programi,Podaci,Varijable,Računanje - 2
Unit-2 Objects and Classes
Introduction to Abstract Data Types
Computers & Programming Languages
Arrays and strings -2 (nizovi i znakovni nizovi)
Elementi programskog jezika PASCAL
Arrays and strings -1 (nizovi i znakovni nizovi)
Chapter 2 Variables.
Chapter 2: Java Fundamentals
Storing Information Each memory cell stores a set number of bits (usually 8 bits, or one byte) (byte addressable)
Data Types Imran Rashid CTO at ManiWeber Technologies.
Chapter 2: Java Fundamentals
Java Programming Review 1
Names of variables, functions, classes
Chapter 2 Variables.
Variables and Constants
Presentation transcript:

Programi,Podaci,Varijable,Računanje - 1 Java Programi,Podaci,Varijable,Računanje - 1

Varijable Objekt čuva svoje stanje u varijabli. Varijabla je komad informacije imenovan identifikatorom. Deklaracija varijable: syntax: <type> <name> int myNumber ; tip naziv Java © - Eugen Mudnić

Data types Svaka varijabla ima točno određen tip podatka Tip određuje: vrijednosti koje varijabla može sadržavati operacije koje se mogu izvršavati nad tipom podatka Dvije kategorije tipova podataka u Javi: Primitivni tip podataka Reference (za referenciranje objekata) Java © - Eugen Mudnić

Primitivni tipovi podataka Primitive Integer int short byte long float double Numeric Real Character Logical char boolean Java programski jezik (a ne platforma) određuju format tipa podataka (nema zbrke s integer tipom podataka). Java © - Eugen Mudnić

Primitivni tipovi podataka Ključna riječ Opis Veličina/Format (integers) byte Byte-length integer 8-bit two's complement short Short integer 16-bit two's complement int Integer 32-bit two's complement long Long integer 64-bit two's complement (real numbers) float Single-precision floating point 32-bit IEEE 754 double Double-precision floating point 64-bit IEEE 754 (other types) char A single character 16-bit Unicode character boolean A boolean value (true or false) true or false Java © - Eugen Mudnić

Cjelobrojni (Integer) tipovi podataka Integer Type Type Size Min. Value Max. Value byte 8bit -128 127 short 16bit -32768 32767 int 32bit -2147483648 2147483647 long 64bit -9223372036854775808 9223372036854775807 Unsigned are not supported ! byte smallerValue; short pageCount; int wordCount; long bigValue; Java © - Eugen Mudnić

Cjelobrojni (Integer) tipovi podataka red color : sign bit byte max 01111111 byte min 10000000 short max 0111111111111111 short min 1000000000000000 int max 01111111111111111111111111111111 int min 10000000000000000000000000000000 long max 01111111....... long min 10000000....... Java © - Eugen Mudnić

Cjelobrojni (Integer) literali svaki integer literal je pretpostavljeno tipa int (by default) 1,-9999, 123456789 – literali tipa int 1L, -9999L, 123456789L – literali tipa long ne mogu se specificirati byte i short literali baza 16 - 0xFA15 ili 0XFA15 baza 8 – 035, 017 (pažljivo s vodećom nulom !) Java © - Eugen Mudnić

Deklariranje cjelobrojnih varijabli long bigOne; // declaration long bigOne=1024147L; // declaration and initialization long bigOne=9999999L, largeOne=254111L; int xCord=0, yCord=0; // Point coordinates int miles =0, yards =0, feet =0; byte luckyNumber = 7; byte smallNumber = 1234; Before use variable must be declared and value must be assigned ! Java © - Eugen Mudnić

Floating Point (pokretni zarez) tipovi podataka Dva osnovna tipa : float –3.4E38 to +3.4E38 , približno 7 točnih znamenki double -1.7E308 to +1.7E308 , približno. 17 točnih znamenki (najmanja nenulta vrijednost je ±4.9E-324) Pridržavanje IEEE 754 standarda za operacije u pokretnom zarezu Java © - Eugen Mudnić

Floating point literal pretpostavljeno da je floating point literal tipa double 1.0,345.768, 34E22 – literali tipa double 1.0f,345.768F, 34E22f – literali tipa float Java © - Eugen Mudnić

Deklaracija Floating Point varijabli double sunDistance= 1.496E8; float electronMass=9E-28F; float hisWeight=92.2F, herWeight=52.3F; float hisWeight=92.2; prevodilac neće izvršti automatsku konverziju u tip float ! Java © - Eugen Mudnić