Code:
// ap8,Bitwise 的各種運算
public class ap8
{
public static void main(String args[])
{
int i=13;
int j=14;
int k=i+j;
short l=27;
String x = "0000000000000000000000000000000000";
String y = "1111111111111111111111111111111111";
String z = "0101010101010100101010101010101010";
String w = "1010101010101011010101010101010101";
String pad = "--------------------------------";
...
09 June, 2013
運算式真假值
StandardCode:
// ap7,運算式真假值
public class ap7
{
public static void main(String args[])
{
int a=126;
int b=-2*a;
boolean c=true;
boolean d=!c; //false
System.out.println("a=" + a);
System.out.println("b=-2*a=" + b);
System.out.println("c=" + c);
System.out.println("d=!c=" + d);
System.out.print("((a>b)?c:d)="+((a>b)?c:d)+"\n"); //true
System.out.print("((ab)?d:c)+"\n");...
運算式的型態轉換
StandardCode:
// ap6,運算式的型態轉換
public class ap6
{
public static void main(String args[])
{
short s=-5;
int i=6;
float f=9.67f;
double d=976e-2; //9.76
System.out.print("(short*integer)=");
System.out.println((s*i));
System.out.print("(double/float)=");
System.out.println((d/f));
System.out.print("(integer+float)=");
System.out.println((i+f));
System.out.print("(double/float)*(integer+float)=");
...
Subscribe to:
Posts (Atom)