线程BA

import java.awt.*;import java.awt.event.*;public class Thread1Frame implements Runnable { StringBuffer buffer=new StringBuffer(); Thread t1,t2; Thread1Frame() { t1=new Thread(this); t2=new Thread(this); } public synchronized void addChar(char c){ if(Thread.cu...
2011-12-27 15:36 | 阅读 857 次 | 评论 0 条

多线程接力

import java.awt.*;import java.awt.event.*;public class DoubleThreadFrame extends Frame implements Runnable,ActionListener{ Thread first,second,third;//创建两个线程 int distance=10; Button redButton,greenButton,blueButton,startButton; public DoubleThreadFrame() { first...
2011-12-27 15:12 | 阅读 2627 次 | 评论 0 条

单词拼写

import java.awt.*;import java.awt.event.*;public class LetterLabel extends Button implements FocusListener,MouseListener{ //构造器 LetterLabel(){ addFocusListener(this); //将当前对象注册为自身的焦点事件监视器 addMouseListener(this); //将当前对象注册为自身的鼠标事件监视器 this.setBackground(Color.cyan...
2011-12-25 22:09 | 阅读 1123 次 | 评论 0 条

日历小程序

import java.util.Calendar;public class MyCalendar{ String[] day; int year=2005,month=0; public void setYear(int year){ this.year=year; } public int getYear(){ return year; } public void setMonth(int month){ this.month=month; } public int getMonth(){...
2011-12-24 17:01 | 阅读 1257 次 | 评论 0 条

信号灯

//SignalCanvas import java.awt.*;public class SignalCanvas extends Canvas{ int red,green,yellow,x,y,r; SignalCanvas(){ setBackground(Color.BLUE); } public void setRed(int red){ this.red=red; } public void setGreen(int green){ this.green=green; } public...
2011-12-21 18:32 | 阅读 725 次 | 评论 0 条

上机实践六 组件及事件处理1

/* *Teacher.java **/public class Teacher{ int numberOne,numberTwo; String operator=""; boolean right; public int giveNumberOne(int n){ numberOne = (int)(Math.random()*n)+1; return numberOne; } public int giveNumberTwo(int n){ numberTwo = (int)(Math.rando...
2011-12-21 16:51 | 阅读 1065 次 | 评论 0 条

字符串的几个简单操作

public class Outprintln{ public static void main(String[] agrs){/* byte[] d="abc美丽的向日葵".getBytes(); System.out.println(d.length); String s = new String(d,0,7); System.out.println(s); String s="1234567890"; MyString ms = new MyString(); ...
2011-12-21 15:05 | 阅读 1098 次 | 评论 0 条

上机实践五自测题2

import java.util.*;class GetToken{ String[] s; public String getToken(int index,String str){ StringTokenizer fenxi=new StringTokenizer(str); int number=fenxi.countTokens(); System.out.println(number); s=new String[number+1]; int k=1; while(fenxi.has...
2011-12-21 09:34 | 阅读 883 次 | 评论 0 条

比较日期大小

import java.util.*;import javax.swing.JOptionPane;public class Simple{ public static void main(String[] agrs){ String str = JOptionPane.showInputDialog("输入第一个年份:"); int firstYear = Integer.parseInt(str); str = JOptionPane.showInputDialog("输入月份:"); int firstMonth...
2011-12-21 09:05 | 阅读 1085 次 | 评论 0 条

处理最大数

import java.math.*;public class BigintegerExample{ public static void main(String[] agrs){ BigInteger n1 = new BigInteger("845955859965866956623646"), n2 = new BigInteger("11111111111111111111111"), result=null; result = n1.add(n2);//加法运算 ...
2011-12-21 09:04 | 阅读 909 次 | 评论 0 条

上机实践五:字符串、时间和数字

public class StringExample{ public static void main(String[] agrs){ String s1 = new String("you are a student"), s2 = new String("how are you"); if(s1.equals(s2)){ System.out.println("s1与s2相同"); }else{ System.out.println("s1与s2不同");...
2011-12-21 08:27 | 阅读 984 次 | 评论 0 条

实验三:猜数字游戏

/*实验三:猜数字游戏*/import javax.swing.JOptionPane;public class GuessNumber{ public static void main(String[] agrs){ System.out.println("猜数字1--100"); int realNumber=(int)(Math.random()*100)+1; int yourGuess = 0; String str = JOptionPane.showInputDialog("输入你的猜测"); ...
2011-12-21 08:24 | 阅读 850 次 | 评论 0 条
浏览17061次
最新评论