More than just a song and dance.. They are objects that store primitive variable values: Integer – stores an int Double – stores a double Character –

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Chapter 2 Review Questions
Constants and Data Types Constants Data Types Reading for this class: L&L,
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
Objects vs. Primitives Primitive Primitive byte, short, int, long byte, short, int, long float, double float, double char char boolean boolean Object (instance.
CSE373 Optional Section Java Collections 11/12/2013 Luyi Lu.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
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.
Copyright © Curt Hill BitWise Operators Packing Logicals with Other Bases as a Bonus.
© 2007 Lawrenceville Press Slide 1 Chapter 10 Arrays  Can store many of the same kind of data together  Allows a collection of related values to be stored.
Data collections Android Club Agenda Array ArrayList HashMap.
Primitive Variables.
CS-1030 Dr. Mark L. Hornick 1 C++ Language Basic control statements and data types.
Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 13: Data structures in C.
In Java.... Variables contain the values of primitive data types Value Types.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
1.2 Primitive Data Types and Variables
A: A: double “4” A: “34” 4.
Java – Variables and Constants By: Dan Lunney. Declaring Variables All variables must be declared before they can be used A declaration takes the form:
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Wrapper Classes  Java offers a convenient way to incorporate, or wrap, a primitive data type into an object, for example, wrapping int into the class.
Characters and Strings
Primitive Data Types 1 In PowerPoint, point at the speaker icon, then click the "Play" button.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
CSC 142 F 1 CSC 142 References and Primitives. CSC 142 F 2 Review: references and primitives  Reference: the name of an object. The type of the object.
“Unboxing” means taking an Integer object and assigning its value to a primitive int. This is done using the.intValue( ) method. Example; Integer z = new.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Integer, Double, and Other Wrapper Classes … Sometimes a primitive value needs to be passed in as an argument, but the method definition creates an object.
CS202 Java Object Oriented Programming Introduction to Collection Classes Chengyu Sun California State University, Los Angeles.
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Fundamentals 2.
Relational Operator and Operations
Agenda Warmup Finish 2.4 Assignments
Multiple variables can be created in one declaration
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.
Type Conversion, Constants, and the String Object
CMSC 202 Static Methods.
Review Operation Bingo
Unit-2 Objects and Classes
Examples of Primitive Values
Can store many of the same kind of data together
Computers & Programming Languages
Wrapper Classes The java.lang package contains wrapper classes that correspond to each primitive type: Primitive Type Wrapper Class byte Byte short Short.
Relational Operators Operator Meaning < Less than > Greater than
Value Types and Reference Types
Can store many of the same kind of data together
Data Types Imran Rashid CTO at ManiWeber Technologies.
Variables Kevin Harville.
Can store many of the same kind of data together
Classes and Objects Static Methods
Suggested self-checks: Section 7.11 #1-11
Variables Here we go.
Variables and Computer Memory
Java: Variables, Input and Arrays
Data Types and Maths Programming Guides.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
Section 6 Primitive Data Types
Presentation transcript:

More than just a song and dance.

They are objects that store primitive variable values: Integer – stores an int Double – stores a double Character – stores a char Boolean – stores a boolean

Sometimes you want a primitive value stored as an object. This allows you to: Store primitives in complex data structures such as ArrayLists They are pass by reference instead of pass by copy They provide some additional helper methods

parseInt(String s) – takes in a String and converts it into the corresponding Integer toHexString(int i) – converts an integer to a hexadecimal String toBinaryString(int i) – converts an integer to a binary String

//Declaring variables Integer x = 5; Double y = 6.7; Character z = 'z'; Boolean flag = false; //Using parseInt String numInText = "29274"; Integer a = Integer.parseInt(numInText); //Performing operation Integer b = x + a; System.out.println(b);

ArrayList numbers = new ArrayList (); numbers.add(3); numbers.add(5); numbers.add(7); System.out.println(numbers);