2004年11月4日
P43 t1
public class test{
public static void main(String[] args){
for(int i=4;i>0;i--){
for(int j=0;j<i;j++){
System.out.print("1");
}
System.out.println();
}
}
}
P43 t2
import java.util.*;
public class test{
public static void main(String[] args){
int[] intarray={2,5,8,4,6};
Arrays.sort(intarray);//进行数组排序
System.out.println("Max is "+intarray[4]);
System.out.println("Min is "+intarray[0]);
}
}
P72 t3
class fulei{
void fulei(int age,String name){
System.out.println(name+"'s age is "+age);
}
}
public class test extends fulei{
public static void main(String[] ages){
fulei m=new test();//这里还有点不明白
m.fulei(20,"lile");
}
}
2004年11月5日
P93 t2
/*
* 创建日期 2004-11-5
*^_^用eclipse做的.偷懒了
*/
/**
* @author lileltp
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
interface Vehicle{
void Start(int x);
void Stop(int y);
}
class Bus implements Vehicle{
/* (非 Javadoc)
* @see Vehicle#Start(int)
*/
public void Start(int x) {
// TODO 自动生成方法存根
}
/* (非 Javadoc)
* @see Vehicle#Stop(int)
*/
public void Stop(int y) {
// TODO 自动生成方法存根
}
}
class Bike implements Vehicle{
/* (非 Javadoc)
* @see Vehicle#Start(int)
*/
public void Start(int x) {
// TODO 自动生成方法存根
System.out.println("这个是bike的方法Start "+x);
}
/* (非 Javadoc)
* @see Vehicle#Stop(int)
*/
public void Stop(int y) {
// TODO 自动生成方法存根
}
}
public class interfaceDemo {
public static void main(String[] args) {
Bike a=new Bike();
a.Start(5);
}
}
P109 t1,2
/*
* 创建日期 2004-11-5
* 判断输入是否为byte类型.
*/
/**
* @author lileltp
*
*/
import javax.swing.JOptionPane;
public class CheckByte {
void CheckByteDemo(String s){
try{
byte b=Byte.parseByte(s);//转换成byte类型,如果不成功抛出异常
System.out.println("This is Byte.");
}catch(NumberFormatException e){
System.out.println("You input is not byte");
}
}
public static void main(String[] args) throws ByteSizeException {
String s=JOptionPane.showInputDialog("Please input");
CheckByte demo=new CheckByte();
demo.CheckByteDemo(s);
}
class ByteSizeException extends Exception{
public ByteSizeException(){
super();
}
}
}