Data Types & VariablesDhrubojyotiKayal
What are data types?Data types in JavaVariablesLiteralsAgenda
classification identifying one of various types of dataThey have special features and requirementsPerform operations on dataThey need memoryWhat are data types?
8 primitive data types, all signed (+,-)Irrespective of environment the data types have same sizeData types in Java
Variables/Fields stores values with specific data typeInstance variables (object fields)Class variables (static fields)Local variables (method fields)Parameters (arguments passed to a method)int age;long creditCardNumber; Terminate with semi-colon or separate with commaint age, long creditCardNumber;Variables
Variable names are case-sensitiveUnlimited length with letters and digitsBegin with letter, ‘$’,’_’Don’t use ‘$’ or ‘_’Whitespace not allowedSubsequent characters may be letters, digits, dollar signs, or underscore charactersUse meaningful namesUse Camelian NotationintcreditCardNumber;Variable naming
Fixed values assigned to variables without computationint age = 32;long creditCardNumber = 135353553566;Literals
Write a simple Java program and declare 3 variables – your age (integer), your credit card number(long), and your bank balance(double)Assign literal values to these fieldsPrint the 3 values in consoleExercise
Q&A

04 data types & variables

  • 1.
    Data Types &VariablesDhrubojyotiKayal
  • 2.
    What are datatypes?Data types in JavaVariablesLiteralsAgenda
  • 3.
    classification identifying oneof various types of dataThey have special features and requirementsPerform operations on dataThey need memoryWhat are data types?
  • 4.
    8 primitive datatypes, all signed (+,-)Irrespective of environment the data types have same sizeData types in Java
  • 5.
    Variables/Fields stores valueswith specific data typeInstance variables (object fields)Class variables (static fields)Local variables (method fields)Parameters (arguments passed to a method)int age;long creditCardNumber; Terminate with semi-colon or separate with commaint age, long creditCardNumber;Variables
  • 6.
    Variable names arecase-sensitiveUnlimited length with letters and digitsBegin with letter, ‘$’,’_’Don’t use ‘$’ or ‘_’Whitespace not allowedSubsequent characters may be letters, digits, dollar signs, or underscore charactersUse meaningful namesUse Camelian NotationintcreditCardNumber;Variable naming
  • 7.
    Fixed values assignedto variables without computationint age = 32;long creditCardNumber = 135353553566;Literals
  • 8.
    Write a simpleJava program and declare 3 variables – your age (integer), your credit card number(long), and your bank balance(double)Assign literal values to these fieldsPrint the 3 values in consoleExercise
  • 9.