Lecture 1 Page 2 - 2 September 2011 - Blog - BioInformatics Pakistan
Thursday, 2017-03-30, 5:27 PM
Welcome Guest | RSS

Login form

Statistics
Total online: 1
Guests: 1
Users: 0

Is Online User
Site Search

Blog

Main » 2011 » September » 2 » Lecture 1 Page 2
10:07 PM
Lecture 1 Page 2


Now Some Basic Examples

1. Basic Data Types:
   Every variable has some data type in JAVA, this data type decides what this variable will store. Some basic data types are as follows:
  • String: As name describes it is used to store strings(Sequence of alphabets) in it. It is used as String s = "Its JAVA course";
  • int: as name shows it stores integer value. It can't store decimal value e.g int a = 20;
  • float and double: These two data types are used to store decimal values, difference in them is the usage of memory. More you will learn with time. It can be used as float x = 2.99;
   
2. Simple Program That Uses Strings:
  • Make new project named StringTest as described before.
  • Write following commands in main method.
    • String x = "Java ";
    • String y = "Course";
    • String z = x+y;
    • System.out.println(z);
  • Test this and try different such statements.
3. Simple Calculations:
  • Make new project named BasicMaths as described before.
  • Write following commands in main method.
    • int a =12;
    • int b =3;
    • int c,d,e,f,g;
    • c= a+b;
    • d= a*b;
    • e= a-b;
    • f= a/b;
    • g= a%b;
    • System.out.println("Addition : "+ a +" + "+ b +" = "+ c );
    • System.out.println("Multiplicaton : "+ a +" * "+ b +" = "+ d );
    • System.out.println("Subtraction : "+ a +" - "+ b +" = "+ e );
    • System.out.println("Division : "+ a +" / "+ b +" = "+ f );
    • System.out.println("Remainder : "+ a +" % "+ b +" = "+ g );
  • Test this and try different such statements.

For Discussion I Will Be Online After 9 PM
(Pakistan) Daily.
You Can Also Leave A Thread At FORUM Which Will Be Answered In 24 Hrs.
Your Assignment After This Lecture Is To Practice All These Tasks And Give Some New Examples At FORUM.

Next Lecture Will Be On Tuesday.


Category: JAVA Online Course | Views: 494 | Added by: Ansari | Rating: 0.0/0
Total comments: 1
1  
You can download discussed project from forum.

Forum

Name *:
Email *:
Code *:
Tag Board
Your Ads
Site friends

Copyright MyCorp © 2017
Free website builderuCoz