04 data types & variables

337 views
275 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
337
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

04 data types & variables

  1. 1. Data Types & Variables<br />DhrubojyotiKayal<br />
  2. 2. What are data types?<br />Data types in Java<br />Variables<br />Literals<br />Agenda<br />
  3. 3. classification identifying one of various types of data<br />They have special features and requirements<br />Perform operations on data<br />They need memory<br />What are data types?<br />
  4. 4. 8 primitive data types, all signed (+,-)<br />Irrespective of environment the data types have same size<br />Data types in Java<br />
  5. 5. Variables/Fields stores values with specific data type<br />Instance variables (object fields)<br />Class variables (static fields)<br />Local variables (method fields)<br />Parameters (arguments passed to a method)<br />int age;<br />long creditCardNumber; <br />Terminate with semi-colon or separate with comma<br />int age, long creditCardNumber;<br />Variables<br />
  6. 6. Variable names are case-sensitive<br />Unlimited length with letters and digits<br />Begin with letter, ‘$’,’_’<br />Don’t use ‘$’ or ‘_’<br />Whitespace not allowed<br />Subsequent characters may be letters, digits, dollar signs, or underscore characters<br />Use meaningful names<br />Use Camelian Notation<br />intcreditCardNumber;<br />Variable naming<br />
  7. 7. Fixed values assigned to variables without computation<br />int age = 32;<br />long creditCardNumber = 135353553566;<br />Literals<br />
  8. 8. Write a simple Java program and declare 3 variables – your age (integer), your credit card number(long), and your bank balance(double)<br />Assign literal values to these fields<br />Print the 3 values in console<br />Exercise<br />
  9. 9. Q&A<br />

×