03:59 ---
\n ขึ้นบรรทัดใหม่
\t  แท็บแนวนอน
\bถอยหลัง1ช่องตัวอักษร
\r เลือนเคอร์เซอร์ไปซ้ายสุด
\\แสดง\
\' แสดง'
\"แสดง"

public class Tabs{
public static void main (String[] args) {
System.out.print("These are our top sellers:\n");
System.out.print("\tComputer grames\n\tCoffee\n");
System.out.println("\tAspirin");
}
}

ผล
These are our top sellers:
        Computer grames
        Coffee
        Aspirin
Press any key to continue . . .
=======================================================================
boolean  เก็บค่าtrue ,false
char        เก็บอักษรแบบUnicode
byte        -128 ถึง+127
short       -32,768ถึง +32,767
int           -2147483648ถึง +2147483647
long        -263ถึง+263 -1
float        -3.4E+38ถึง 3.4E+38
double    -1.7E+308ถึง1.7+308



public class Tabs{
public static void main (String[] args) {

double m= 3.12;
float x=12.f;

System.out.println(m);
System.out.println(x);
}
}
ผล
3.12
12.0
Press any key to continue . . .
======================================================================
public class increment{
public static void main (String[] args) {
int x,y;
x=10;
y=x++;
System.out.println("x="+x+" y= "+y);
y = ++x;
System.out.println("x="+x+" y= "+y);
}
}

ผล

x=11 y= 10
x=12 y= 12
Press any key to continue . . .

0 ความคิดเห็น:

แสดงความคิดเห็น