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...
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...
import java.awt.*;import java.awt.event.*;public class LetterLabel extends Button implements FocusListener,MouseListener{ //构造器 LetterLabel(){ addFocusListener(this); //将当前对象注册为自身的焦点事件监视器 addMouseListener(this); //将当前对象注册为自身的鼠标事件监视器 this.setBackground(Color.cyan...
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(){...
//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...
/* *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...
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(); ...
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...
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...
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);//加法运算 ...
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不同");...
/*实验三:猜数字游戏*/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("输入你的猜测"); ...