31datatype

31datatype - Data Types 3.1 Using Data Types Data type Set...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
3.1 Using Data Types Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · October 18, 2008 10:26 AM 2 Data Types Data type. Set of values and operations on those values. Primitive types. Ops directly translate to machine instructions. We want to write programs that process other types of data. ! Colors, pictures, strings, input streams, … ! Complex numbers, vectors, matrices, polynomials, … ! Points, polygons, charged particles, celestial bodies, … Operations Set of Values Data Type not, and, or, xor true , false boolean double int add, subtract, multiply any of 2 64 possible reals add, subtract, multiply -2 31 to 2 31 - 1 3 Objects Object. Holds a data type value; variable name refers to object. Impact. Enables us to create our own data types; define operations on them; and integrate into our programs. length, substring, compare sequence of characters String Operations Set of Values Data Type get red component, brighten 24 bits Color Picture get/set color of pixel (i, j) 2D array of colors 4 Constructors and Methods To construct a new object: Use keyword new and name of data type. To apply an operation: Use name of object, the dot operator , and the name of the method .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image Processing 6 Color Data Type Color. A sensation in the eye from electromagnetic radiation. Set of values. [RGB representation] 256 3 possible values, which quantify the amount of red, green, and blue, each on a scale of 0 to 255. 255 0 105 G R Color B 7 Color Data Type Color. A sensation in the eye from electromagnetic radiation. Set of values. [RGB representation] 256 3 possible values, which quantify the amount of red, green, and blue, each on a scale of 0 to 255. API. Application Programming Interface. http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Color.html 8 Albers Squares Josef Albers. Revolutionized the way people think about color. Homage to the Square by Josef Albers (1949-1975)
Background image of page 2
9 % java AlbersSquares 9 90 166 100 100 100 Albers Squares Josef Albers. Revolutionized the way people think about color. 10 Using Colors in Java public class AlbersSquares { public static void main ( String [] args ) { } } to access Color library first color second color first square second square 11 Monochrome Luminance Monochrome luminance. Effective brightness of a color.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 10

31datatype - Data Types 3.1 Using Data Types Data type Set...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online