Java ISU Variables - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Java ISU Variables

Description:

Java ISU - Variables. By Christina Lee. And Andrew James. Variables. an item of data named by an identifier ... must explicitly provide a name that begins with ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 11
Provided by: aaa2112
Category:

less

Transcript and Presenter's Notes

Title: Java ISU Variables


1
Java ISU - Variables
  • By Christina Lee
  • And Andrew James

2
Variables
  • an item of data named by an identifier
  • must explicitly provide a name that begins with a
    letter and a type for each variable
  • a variable declaration type name
  • The variable's scope determined implicitly by
    the location of the variable declaration

3
Data Type
  • determines the values that the variable can
    contain and the operations that can be performed
    on it
  • contains a single value of the appropriate size
    and format for its type a number, a character,
    or a boolean value.

4
Data Type
5
Assignment Operators
  • performs a function on one, two, or three
    operands
  • allow you to perform an arithmetic, shift, or
    bitwise operation and an assignment operation all
    with one operator.

6
Assignment Operators
7
Example - MaxVariablesDemo
  • public class MaxVariablesDemo
  • public static void main(String args)  
  • // integers
  • byte largestByte Byte.MAX_VALUE
  • short largestShort Short.MAX_VALUE
  • int largestInteger Integer.MAX_VALUE
  • long largestLong Long.MAX_VALUE 
  • // real numbers
  • float largestFloat Float.MAX_VALUE
  • double largestDouble Double.MAX_VALUE 
  • // other primitive types
  • char aChar 'S'
  • boolean aBoolean true

8
Example - MaxVariablesDemo
  • // display them all
  • System.out.println("The largest byte value is "
    largestByte) System.out.println("The
    largest short value is " largestShort)
    System.out.println("The largest integer value is
    " largestInteger) System.out.println("T
    he largest long value is " largestLong) 
  • System.out.println("The largest float value is
    " largestFloat) System.out.println("The
    largest double value is " largestDouble) 
  • if (Character.isUpperCase(aChar))
  • System.out.println("The character " aChar "
    is upper case.")
  • else
  • System.out.println("The character "
    aChar " is lower case.")
  • System.out.println("The value of aBoolean is "
    aBoolean)

9
Output of the program
  • The largest byte value is 127
  • The largest short value is 32767
  • The largest integer value is 2147483647
  • The largest long value is 9223372036854775807
  • The largest float value is 3.40282e38
  • The largest double value is 1.79769e308
  • The character S is upper case.
  • The value of aBoolean is true

10
The End
  • Thank you for your listening )
Write a Comment
User Comments (0)
About PowerShow.com