1 MATERI PENDUKUNG TIPE DATA Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.

Slides:



Advertisements
Similar presentations
 Variables  What are they?  Declaring and initializing variables  Common uses for variables  Variables you get “for free” in Processing ▪ Aka: Built-in.
Advertisements

Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Data Types and Expressions
Types and Variables. Computer Programming 2 C++ in one page!
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Variables Pepper. Variable A variable –box –holds a certain type of value –value inside the box can change Example –A = 2B+1 –Slope = change in y / change.
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Constants Variables change, constants don't final = ; final double PI = ; … area = radius * radius * PI; see Liang, p. 32 for full code.
Review Binary –Each digit place is a power of 2 –Any two state phenomenon can encode a binary number –The number of bits (digits) required directly relates.
Data types and variables
Characters and Strings. Characters In Java, a char is a primitive type that can hold one single character A character can be: –A letter or digit –A punctuation.
JavaScript, Fourth Edition
Chapter 2 Data Types, Declarations, and Displays
ASP.NET Programming with C# and SQL Server First Edition
JavaScript, Third Edition
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
Fundamental data types Horstmann Chapter 4. Constants Variables change, constants don't final = ; final double PI = ; … areaOfCircle = radius *
String Escape Sequences
1 Chapter 2 JAVA FUNDAMENTALS CONT’D. 2 PRIMITIVE DATA TYPES Computer programs operate on data values. Values in Java are classified according to their.
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
Chapter 2 Data Types, Declarations, and Displays.
Objectives You should be able to describe: Data Types
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
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.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
 Pearson Education, Inc. All rights reserved Formatted Output.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X.
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.
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.
Lecture #5 Introduction to C++
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Data Types and Operations On Data Objective To understand what data types are The need to study data types To differentiate between primitive types and.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Java Overview. Comments in a Java Program Comments can be single line comments like C++ Example: //This is a Java Comment Comments can be spread over.
Variables in Java x = 3;. What is a variable?  A variable is a placeholder in memory used by programmers to store information for a certain amount of.
Chapter 2 Variables.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Lab 4 - Variables. Information Hiding General Principle: – Restrict the access to variables and methods as much as possible Can label instance variables.
COMP Primitive and Class Types Yi Hong May 14, 2015.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
A data type in a programming language is a set of data with values having predefined characteristics.data The language usually specifies:  the range.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Primitive Data Types. int This is the type you are familiar with and have been using Stores an integer value (whole number) between -2,147,483,648 (-2.
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
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.
28 Formatted Output.
Chapter 2 Variables.
Java Variables and Types
Multiple variables can be created in one declaration
Variables and Primative Types
Chapter 2.
IDENTIFIERS CSC 111.
Chapter 2 Variables.
Introduction to Primitive Data types
Chapter 2: Java Fundamentals
Chapter 2 Variables.
Variables and Constants
Introduction to Primitive Data types
Presentation transcript:

1 MATERI PENDUKUNG TIPE DATA Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0

2 Data type Data types classify the kind of information that certain Java programming elements can contain. Data types fall into two main categories –Primitive or basic –Composite or reference Naturally, different kinds of data types can hold different kinds and amounts of information. You can convert the data type of a variable to a different type, within limits: you cannot cast to or from the boolean type, and you cannot cast an object to an object of an unrelated class. Java will prevent you from risking your data. This means it will easily let you convert a variable or object to a larger type, but will try to prevent you from converting it to a smaller type. When you change a data type with a larger capacity to one with a smaller capacity, you must use a type of statement called a type cast

3 Primitive data types Primitive, or basic, data types are classified as Boolean (specifying an on/off state), character (for single characters and Unicode characters), integer (for whole numbers), or floating-point (for decimal numbers). In code, primitive data types are all lower case. The Boolean data type is called boolean, and takes one of two values: true or false. Java doesn't store these values numerically, but uses the boolean data type to store these values. The character data type is called char and takes single Unicode characters with values up to 16 bits long. In Java, Unicode characters (letters, special characters, and punctuation marks) are put between single quotation marks: 'b'. Java's Unicode default value is \u0000, ranging from \u0000 to \uFFFF. Briefly, the Unicode numbering system takes numbers from 0 to 65535, but the numbers must be specified in hexadecimal notation, preceded by the escape sequence \u

4 Composite data types Each of the data types above accepts one number, one character, or one state. Composite, or reference, data types consist of more than a single element. Composite data types are of two kinds: classes and arrays. Class and array names start with an upper case letter and are camel-capitalized (that is, the first letter of each natural word is capitalized within the name, for instance, NameOfClass). A class is a complete and coherent piece of code that defines a logically unified set of objects and their behavior. For more information on classes, see Object-Oriented Programming in Java. Any class can be used as a data type once it has been created and imported into the program. Because the String class is the class most often used as a data type, we will focus on it in this chapter.