Frequently, Java programs use group of characters called strings. A java string is a class, not a primitive data type. The java string is part of the java.lang library, which can be accessed in any java program.
However String is a class, it begins with an UPPER CASE letter. Although all data types are with lower case letters.
Declare variables:
Int a,b,c;
Float red=1.22;
Int a=5, b=c, d=77;
String sname;
String nic 010-10125-5128;
Boolean flag= true;
Boolean choice true;
Character grade-;’f’;
One ‘f’ in quote is character, but more than one character in a quote is "String". e.g. ‘lkihjdw’;
JAVA Contents:
Static final double d1=3.14;
Static final int fees = 500;
JAVA type casting:
Int a,b;
Double c;
C=a+b;
The above syntax is wrong because data types are different.
C=(double)a+ (double)b;
The above statement is correct. We change the data type.
Escape sequences:
\n-------Line feed.
\t--------tab ahead 6 to 8 character on a line.
\r-------carriage or return (like Enter key).
\b-------backspace.
\f------- form feed (printer).
\’--------single quote marks
No comments:
Post a Comment