张孝祥《Java就业培训教程》源代码 02 部分
《Java就业培训教程》 作者:张孝祥 书中源码
《Java就业培训教程》P34源码
程序清单:Promote.java
class Promote
{
public static void main(String args[])
{
byte b = 50;
char c = 'a';
short s = 1024;
int i = 50000;
float f = 5.67f;
double d = .1234;
double result = (f * b) + (i / c) - (d * s);
System.out.println((f * b) + " + " + (i / c) + " - " + (d * s));
System.out.println("result = " + result);
}
}
《Java就业培训教程》P35源码
程序清单:TestScope.java
public class TestScope
{
public static void main(String[] args)
{
int x = 12;
{
int q = 96; // x和q都可用
System.out.println("x is "+x);
System.out.println("q is "+q);
}
q = x; /* 错误的行,只有x可用, q 超出了作用域范围 */
System.out.println("x is "+x);
}
}
《Java就业培训教程》P37源码
程序清单:TestVar.java
public class TestVar
{
public static void main(String [] args)
{
int x;//应改为int x=0;
x=x+1; //这个x由于没有初始化,编译会报错。
System.out.println("x is "+x);
}
}
程序清单:Func1.java
public class Func1
{
public static void main(String [] args)
{
/* 下面是打印出第一个矩形的程序代码*/
for(int i=0;i<3;i++)
{
for(int j=0;j<5;j++)
{
System.out.print("*");
&
相关文档:
==========================================
xml文件
<?xml version="1.0" encoding="GB2312"?>
<RESULT>
<VALUE>
<NO>A1234</NO>
<ADDR>四川省XX县XX镇XX路X段XX号</ADDR>
</VALUE>
<VALUE>
<NO>B1234</NO>
<ADDR>四川省XX市XX乡XX ......
Java毫秒时间计算时,千万要注意int和long的使用,看下例,小心别踩了雷。
/**
* java时间计算(int和long要注意,一定要选择long)
* @author 崔卫兵
*
*/
public class TimeTester {
/**
* 计算几天前的毫秒数
& ......
/*
一共3个移位运算符,左移位<<,右移位>>和无符号移位>>>。左移位<<在低位处补0。右移位>>若值为正则在高位插入0,若值为负则在高位插入1。无符号右移位>>>无论正负都在高位处插入0。
非运算符~
&对两个整型操作数中对应位执行布尔代数,两个位都为1时输出1,否则0。
......
class Link
{
private Node head;
public Link(Node head)
{
this.head=head;
}
public void addNode(Node node)
{
Node p=head;
while(true)
{
if(!p.hasNext())
{
p.setNext(node);
break;
}
p=p.getNext();
}
}
//插入节
public void insertNode(Node p,Node q)
{
q.setNext(p.getNext());
p.se ......