当前位置:首页 » 以太坊知识 » 以太坊java源代码

以太坊java源代码

发布时间: 2021-05-22 07:31:55

『壹』 求编写一个超级简单的Java的程序源代码

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class Login {

public static void main(String args[]) {
LoginFrm frame = new LoginFrm();
}
}

class LoginFrm extends JFrame implements ActionListener{
JLabel nameLabel=new JLabel("用户名:");
JLabel pwdLabel=new JLabel("密码:");
JTextField name=new JTextField(10);
JPasswordField password=new JPasswordField(10);
JButton butnSure=new JButton("确定");
JButton butnCancel=new JButton("取消");
public LoginFrm() {
super("登陆");
setBounds(500, 200, 280, 220);
setVisible(true);
setLayout(null);
nameLabel.setBounds(45, 20, 100, 25);
add(nameLabel);
add(name);
name.setBounds(105, 20, 110, 25);
add(pwdLabel);
pwdLabel.setBounds(45, 60, 100, 25);
add(password);
password.setBounds(105, 60, 110, 25);
add(butnSure);
butnSure.setBounds(45, 100, 80, 25);
add(butnCancel);
butnCancel.setBounds(135, 100, 80, 25);
butnSure.addActionListener(this);
butnCancel.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();//刷新
}

public void actionPerformed(ActionEvent e) {
if (e.getSource() ==butnSure){
System.out.println("用户名:"+name.getText());
System.out.println("密码:"+name.getText());
if("admin".equals(name.getText().trim())&&"123".equals(password.getText().trim())){
this.dispose();
new MainFrm("用户界面",name.getText().trim(),password.getText().trim());
}else {
JOptionPane.showMessageDialog(this, "用户不存在");
}
}else if(e.getSource()==butnCancel){
System.exit(1);
}
}

class MainFrm extends JFrame{
private JLabel info;

public MainFrm(String s,String name,String password) {
super(s);
setBounds(400, 200, 500, 400);
setLayout(new FlowLayout());
info=new JLabel("登陆成功,用户名:"+name+",密码:"+password);
add(info);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();
}
}
}

『贰』 java开发的网盘源代码

傻啊,上面那种你也去下载!

『叁』 谁能给我个java源代码

import javax.swing.*;
import java.awt.*;
import javax.swing.border.LineBorder;
import java.awt.event.*;public class TicTacToe extends JApplet
{
private char whoseTurn='X';
private Cell[][] cell=new Cell[3][3];
private JLabel jlblStatus=new JLabel("X's turn to play");
public void init()
{
JPanel p=new JPanel();
p.setLayout(new GridLayout(3,3,0,0));
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
p.add(cell[i][j]=new Cell()); p.setBorder(new LineBorder(Color.red,1));
jlblStatus.setBorder(new LineBorder(Color.yellow,1));
this.getContentPane().add(p,BorderLayout.CENTER);
this.getContentPane().add(jlblStatus,BorderLayout.SOUTH);
}
public void start()
{}
public static void main(String[] args)
{
JFrame frame=new JFrame("TicTacToe");
TicTacToe applet=new TicTacToe();
frame.getContentPane().add(applet,BorderLayout.CENTER);
applet.init();
applet.start();
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation(
(screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2); frame.setSize(300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public boolean isFull()
{
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(cell[i][j].getToken()==' ')
return false;
return true;
}
public boolean isWin(char token)
{
for(int i=0;i<3;i++)
if((cell[i][0].getToken()==token)
&&(cell[i][1].getToken()==token)
&&(cell[i][2].getToken()==token))
{
return true;
}
for(int j=0;j<3;j++)
if((cell[0][j].getToken()==token)
&&(cell[1][j].getToken()==token)
&&(cell[2][j].getToken()==token))
{
return true;
}
if((cell[0][0].getToken()==token)
&&(cell[1][1].getToken()==token)
&&(cell[2][2].getToken()==token))
{
return true;
}
if((cell[0][2].getToken()==token)
&&(cell[1][1].getToken()==token)
&&(cell[2][0].getToken()==token))
{
return true;
}
return false;
}
public class Cell extends JPanel implements MouseListener
{
private char token=' ';
public Cell()
{
setBorder(new LineBorder(Color.black,1));
addMouseListener(this);
}
public char getToken()
{
return token;
}
public void setToken(char c)
{
token=c;
repaint();
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
if(token=='X')
{
g.drawLine(10,10,getSize().width-10,getSize().height-10);
g.drawLine(getSize().width-10,10,10,getSize().height-10);
}
else if(token=='O')
{
g.drawOval(10,10,getSize().width-20,getSize().height-20);
}
}
public void mouseClicked(MouseEvent e)
{
if(token==' ')
{
if(whoseTurn=='X')
{
setToken('X');
whoseTurn='O';
jlblStatus.setText("O's turn");
if(isWin('X'))
{
JOptionPane.showMessageDialog(this,"X won! ","提示",
JOptionPane.YES_NO_CANCEL_OPTION);
jlblStatus.setText("X won! The game is over");
}
else if(isFull())
{
JOptionPane.showMessageDialog(this,"The game is over","提示",
JOptionPane.INFORMATION_MESSAGE);
jlblStatus.setText("Draw! The game is over");
}
}
else if(whoseTurn=='O')
{
setToken('O');
whoseTurn='X';
jlblStatus.setText("X's turn");
if(isWin('O'))
{
JOptionPane.showMessageDialog(this, "Y won! ","提示",
JOptionPane.INFORMATION_MESSAGE);
jlblStatus.setText("O won! The game is over");
}
else if(isFull())
{
JOptionPane.showMessageDialog(this,"The game is over","提示",
JOptionPane.INFORMATION_MESSAGE);
jlblStatus.setText("Draw! The game is over");
}
}
}
}
public void mousePressed(MouseEvent e)
{}
public void mouseReleased(MouseEvent e)
{}
public void mouseEntered(MouseEvent e)
{}
public void mouseExited(MouseEvent e)
{}
}
}//一个简单JAVA #字三关 的游戏代码

『肆』 求JAVA的一些源代码

这是一个实体类.

import java.util.Date;

/**
* UserInfo generated by MyEclipse Persistence Tools
*/

public class UserInfo implements java.io.Serializable {

// Fields

private Integer id;

private String name;

private String password;

private String realname;

private String gender;

private String orgDept;

private Integer eDegree;

private Integer country;

private Integer district;

private Integer phone;

private String email;

private String userRight;

private Date registerTime;

private String registerStatus;

private Date admitTime;

private String adminOper;

private Integer loginNum;

private Date loginLasttime;

private String loginLastIp;

// Constructors

/** default constructor */
public UserInfo() {
}

/** minimal constructor */
public UserInfo(String name, String password, String realname,
String orgDept, Integer phone, String email) {
this.name = name;
this.password = password;
this.realname = realname;
this.orgDept = orgDept;
this.phone = phone;
this.email = email;
}

/** full constructor */
public UserInfo(String name, String password, String realname,
String gender, String orgDept, Integer eDegree, Integer country,
Integer district, Integer phone, String email, String userRight,
Date registerTime, String registerStatus, Date admitTime,
String adminOper, Integer loginNum, Date loginLasttime,
String loginLastIp) {
this.name = name;
this.password = password;
this.realname = realname;
this.gender = gender;
this.orgDept = orgDept;
this.eDegree = eDegree;
this.country = country;
this.district = district;
this.phone = phone;
this.email = email;
this.userRight = userRight;
this.registerTime = registerTime;
this.registerStatus = registerStatus;
this.admitTime = admitTime;
this.adminOper = adminOper;
this.loginNum = loginNum;
this.loginLasttime = loginLasttime;
this.loginLastIp = loginLastIp;
}

// Property accessors

public Integer getId() {
return this.id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getPassword() {
return this.password;
}

public void setPassword(String password) {
this.password = password;
}

public String getRealname() {
return this.realname;
}

public void setRealname(String realname) {
this.realname = realname;
}

public String getGender() {
return this.gender;
}

public void setGender(String gender) {
this.gender = gender;
}

public String getOrgDept() {
return this.orgDept;
}

public void setOrgDept(String orgDept) {
this.orgDept = orgDept;
}

public Integer getEDegree() {
return this.eDegree;
}

public void setEDegree(Integer eDegree) {
this.eDegree = eDegree;
}

public Integer getCountry() {
return this.country;
}

public void setCountry(Integer country) {
this.country = country;
}

public Integer getDistrict() {
return this.district;
}

public void setDistrict(Integer district) {
this.district = district;
}

public Integer getPhone() {
return this.phone;
}

public void setPhone(Integer phone) {
this.phone = phone;
}

public String getEmail() {
return this.email;
}

public void setEmail(String email) {
this.email = email;
}

public String getUserRight() {
return this.userRight;
}

public void setUserRight(String userRight) {
this.userRight = userRight;
}

public Date getRegisterTime() {
return this.registerTime;
}

public void setRegisterTime(Date registerTime) {
this.registerTime = registerTime;
}

public String getRegisterStatus() {
return this.registerStatus;
}

public void setRegisterStatus(String registerStatus) {
this.registerStatus = registerStatus;
}

public Date getAdmitTime() {
return this.admitTime;
}

public void setAdmitTime(Date admitTime) {
this.admitTime = admitTime;
}

public String getAdminOper() {
return this.adminOper;
}

public void setAdminOper(String adminOper) {
this.adminOper = adminOper;
}

public Integer getLoginNum() {
return this.loginNum;
}

public void setLoginNum(Integer loginNum) {
this.loginNum = loginNum;
}

public Date getLoginLasttime() {
return this.loginLasttime;
}

public void setLoginLasttime(Date loginLasttime) {
this.loginLasttime = loginLasttime;
}

public String getLoginLastIp() {
return this.loginLastIp;
}

public void setLoginLastIp(String loginLastIp) {
this.loginLastIp = loginLastIp;
}

}

『伍』 为什么大多数区块链项目不使用java开发

区块链项目对效率的要求比较高,所以大多数核心源码的开发都是使用c/c++。但是如果是做都区块链项目,除非要对源代码进行大量的调整,否则也不见得就不选择使用java。一般的dapp应用,使用java开发应该也是不错的选择。比如以太坊区块链的话,针对java的有web3j的类库,十分方便;比特币的话有bitcoinj类库,也很好用。还是要看还是什么级别的应用,要做什么,以及团队的情况吧。

分享两个java区块链教程:

  1. java比特币详解

  2. java以太坊开发

『陆』 求java案例源代码 越多越好!

importjava.awt.*;
importjava.awt.event.*;
importjava.lang.*;
importjavax.swing.*;

{
//声明三个面板的布局
GridLayoutgl1,gl2,gl3;
Panelp0,p1,p2,p3;
JTextFieldtf1;
TextFieldtf2;
Buttonb0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26;
StringBufferstr;//显示屏所显示的字符串
doublex,y;//x和y都是运算数
intz;//Z表示单击了那一个运算符.0表示"+",1表示"-",2表示"*",3表示"/"
staticdoublem;//记忆的数字
publicCounter()
{
gl1=newGridLayout(1,4,10,0);//实例化三个面板的布局
gl2=newGridLayout(4,1,0,15);
gl3=newGridLayout(4,5,10,15);

tf1=newJTextField(27);//显示屏
tf1.setHorizontalAlignment(JTextField.RIGHT);
tf1.setEnabled(false);
tf1.setText("0");
tf2=newTextField(10);//显示记忆的索引值
tf2.setEditable(false);
//实例化所有按钮、设置其前景色并注册监听器
b0=newButton("Backspace");
b0.setForeground(Color.red);
b0.addActionListener(newBt());
b1=newButton("CE");
b1.setForeground(Color.red);
b1.addActionListener(newBt());
b2=newButton("C");
b2.setForeground(Color.red);
b2.addActionListener(newBt());
b3=newButton("MC");
b3.setForeground(Color.red);
b3.addActionListener(newBt());
b4=newButton("MR");
b4.setForeground(Color.red);
b4.addActionListener(newBt());
b5=newButton("MS");
b5.setForeground(Color.red);
b5.addActionListener(newBt());
b6=newButton("M+");
b6.setForeground(Color.red);
b6.addActionListener(newBt());
b7=newButton("7");
b7.setForeground(Color.blue);
b7.addActionListener(newBt());
b8=newButton("8");
b8.setForeground(Color.blue);
b8.addActionListener(newBt());
b9=newButton("9");
b9.setForeground(Color.blue);
b9.addActionListener(newBt());
b10=newButton("/");
b10.setForeground(Color.red);
b10.addActionListener(newBt());
b11=newButton("sqrt");
b11.setForeground(Color.blue);
b11.addActionListener(newBt());
b12=newButton("4");
b12.setForeground(Color.blue);
b12.addActionListener(newBt());
b13=newButton("5");
b13.setForeground(Color.blue);
b13.addActionListener(newBt());
b14=newButton("6");
b14.setForeground(Color.blue);
b14.addActionListener(newBt());
b15=newButton("*");
b15.setForeground(Color.red);
b15.addActionListener(newBt());
b16=newButton("%");
b16.setForeground(Color.blue);
b16.addActionListener(newBt());
b17=newButton("1");
b17.setForeground(Color.blue);
b17.addActionListener(newBt());
b18=newButton("2");
b18.setForeground(Color.blue);
b18.addActionListener(newBt());
b19=newButton("3");
b19.setForeground(Color.blue);
b19.addActionListener(newBt());
b20=newButton("-");
b20.setForeground(Color.red);
b20.addActionListener(newBt());
b21=newButton("1/X");
b21.setForeground(Color.blue);
b21.addActionListener(newBt());
b22=newButton("0");
b22.setForeground(Color.blue);
b22.addActionListener(newBt());
b23=newButton("+/-");
b23.setForeground(Color.blue);
b23.addActionListener(newBt());
b24=newButton(".");
b24.setForeground(Color.blue);
b24.addActionListener(newBt());
b25=newButton("+");
b25.setForeground(Color.red);
b25.addActionListener(newBt());
b26=newButton("=");
b26.setForeground(Color.red);
b26.addActionListener(newBt());

//实例化四个面板
p0=newPanel();
p1=newPanel();
p2=newPanel();
p3=newPanel();
//创建一个空字符串缓冲区
str=newStringBuffer();

//添加面板p0中的组件和设置其在框架中的位置和大小
p0.add(tf1);
p0.setBounds(10,25,300,40);
//添加面板p1中的组件和设置其在框架中的位置和大小
p1.setLayout(gl1);
p1.add(tf2);
p1.add(b0);
p1.add(b1);
p1.add(b2);
p1.setBounds(10,65,300,25);
//添加面板p2中的组件并设置其的框架中的位置和大小
p2.setLayout(gl2);
p2.add(b3);
p2.add(b4);
p2.add(b5);
p2.add(b6);
p2.setBounds(10,110,40,150);
//添加面板p3中的组件并设置其在框架中的位置和大小
p3.setLayout(gl3);//设置p3的布局
p3.add(b7);
p3.add(b8);
p3.add(b9);
p3.add(b10);
p3.add(b11);
p3.add(b12);
p3.add(b13);
p3.add(b14);
p3.add(b15);
p3.add(b16);
p3.add(b17);
p3.add(b18);
p3.add(b19);
p3.add(b20);
p3.add(b21);
p3.add(b22);
p3.add(b23);
p3.add(b24);
p3.add(b25);
p3.add(b26);
p3.setBounds(60,110,250,150);
//设置框架中的布局为空布局并添加4个面板
setLayout(null);
add(p0);
add(p1);
add(p2);
add(p3);
setResizable(false);//禁止调整框架的大小
//匿名类关闭窗口
addWindowListener(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente1)
{
System.exit(0);
}
});
setBackground(Color.lightGray);
setBounds(100,100,320,280);
setVisible(true);

}
//构造监听器

{
publicvoidactionPerformed(ActionEvente2)
{
try{

if(e2.getSource()==b1)//选择"CE"清零
{
tf1.setText("0");//把显示屏清零
str.setLength(0);//清空字符串缓冲区以准备接收新的输入运算数
}
elseif(e2.getSource()==b2)//选择"C"清零
{
tf1.setText("0");//把显示屏清零
str.setLength(0);
}
elseif(e2.getSource()==b23)//单击"+/-"选择输入的运算数是正数还是负数
{
x=Double.parseDouble(tf1.getText().trim());
tf1.setText(""+(-x));
}
elseif(e2.getSource()==b25)//单击加号按钮获得x的值和z的值并清空y的值
{
x=Double.parseDouble(tf1.getText().trim());
str.setLength(0);//清空缓冲区以便接收新的另一个运算数
y=0d;
z=0;
}
elseif(e2.getSource()==b20)//单击减号按钮获得x的值和z的值并清空y的值
{
x=Double.parseDouble(tf1.getText().trim());
str.setLength(0);
y=0d;
z=1;
}
elseif(e2.getSource()==b15)//单击乘号按钮获得x的值和z的值并清空y的值
{
x=Double.parseDouble(tf1.getText().trim());
str.setLength(0);
y=0d;
z=2;
}
elseif(e2.getSource()==b10)//单击除号按钮获得x的值和z的值并空y的值
{
x=Double.parseDouble(tf1.getText().trim());
str.setLength(0);
y=0d;
z=3;
}
elseif(e2.getSource()==b26)//单击等号按钮输出计算结果
{
str.setLength(0);
switch(z)
{
case0:tf1.setText(""+(x+y));break;
case1:tf1.setText(""+(x-y));break;
case2:tf1.setText(""+(x*y));break;
case3:tf1.setText(""+(x/y));break;
}
}
elseif(e2.getSource()==b24)//单击"."按钮输入小数
{
if(tf1.getText().trim().indexOf(′.′)!=-1)//判断字符串中是否已经包含了小数点
{

}
else//如果没数点有小
{
if(tf1.getText().trim().equals("0"))//如果初时显示为0
{
str.setLength(0);
tf1.setText((str.append("0"+e2.getActionCommand())).toString());
}
elseif(tf1.getText().trim().equals(""))//如果初时显示为空则不做任何操作
{
}
else
{
tf1.setText(str.append(e2.getActionCommand()).toString());
}
}

y=0d;

}
elseif(e2.getSource()==b11)//求平方根
{
x=Double.parseDouble(tf1.getText().trim());
tf1.setText("数字格式异常");
if(x<0)
tf1.setText("负数没有平方根");
else
tf1.setText(""+Math.sqrt(x));
str.setLength(0);
y=0d;
}
elseif(e2.getSource()==b16)//单击了"%"按钮
{
x=Double.parseDouble(tf1.getText().trim());
tf1.setText(""+(0.01*x));
str.setLength(0);
y=0d;
}
elseif(e2.getSource()==b21)//单击了"1/X"按钮
{

x=Double.parseDouble(tf1.getText().trim());
if(x==0)
{

tf1.setText("除数不能为零");
}
else
{
tf1.setText(""+(1/x));
}
str.setLength(0);
y=0d;
}
elseif(e2.getSource()==b3)//MC为清除内存
{
m=0d;
tf2.setText("");
str.setLength(0);
}
elseif(e2.getSource()==b4)//MR为重新调用存储的数据
{
if(tf2.getText().trim()!="")//有记忆数字
{
tf1.setText(""+m);
}
}
elseif(e2.getSource()==b5)//MS为存储显示的数据
{

m=Double.parseDouble(tf1.getText().trim());
tf2.setText("M");
tf1.setText("0");
str.setLength(0);
}
elseif(e2.getSource()==b6)//M+为将显示的数字与已经存储的数据相加要查看新的数字单击MR
{
m=m+Double.parseDouble(tf1.getText().trim());
}
else//选择的是其他的按钮
{
if(e2.getSource()==b22)//如果选择的是"0"这个数字键
{
if(tf1.getText().trim().equals("0"))//如果显示屏显示的为零不做操作
{

}
else
{
tf1.setText(str.append(e2.getActionCommand()).toString());
y=Double.parseDouble(tf1.getText().trim());
}
}
elseif(e2.getSource()==b0)//选择的是“BackSpace”按钮
{
if(!tf1.getText().trim().equals("0"))//如果显示屏显示的不是零
{
if(str.length()!=1)
{
tf1.setText(str.delete(str.length()-1,str.length()).toString());//可能抛出字符串越界异常
}
else
{
tf1.setText("0");
str.setLength(0);
}
}
y=Double.parseDouble(tf1.getText().trim());
}
else//其他的数字键
{
tf1.setText(str.append(e2.getActionCommand()).toString());
y=Double.parseDouble(tf1.getText().trim());
}
}
}
catch(NumberFormatExceptione){
tf1.setText("数字格式异常");
}
catch(){
tf1.setText("字符串索引越界");
}
}
}
publicstaticvoidmain(Stringargs[])
{
newCounter();
}

}

『柒』 求java一个简单点的源代码,要完整可运行的

商品社会拒绝白干,第一,没有人会给你这个程序。第二,就算有人给你,他也不会耐心告诉你怎么配置,怎么装数据库。怎么运行。 随随便便来这里就想白要,你觉得可能吗。我说话可能不好听,但是这是事实。

『捌』 求Java源程序代码,一整套的就可以,不限制类型

//Threader.java
import java.awt.Graphics;
import java.awt.Color;

public class Threader extends java.awt.Canvas implements Runnable {
int myPosition =0;
String myName;
int numberofSteps=600;
boolean keepRunning = true;
//构造函数
public Threader (String inName){
myName=new String (inName);
}

public synchronized void paint(Graphics g){
//为线程竞赛画一条直线
g.setColor (Color.black);
g.drawLine (0,getSize().height/2,getSize().width,getSize().height/2);

//画竞赛者.
g.setColor (Color.yellow);
g.fillOval((myPosition*getSize().width/numberofSteps),0,15,getSize().height);
}

public void stop(){
keepRunning = false;
}

public void run(){
//循环直到竞赛停止
while ((myPosition <numberofSteps)&& keepRunning){
myPosition++;
repaint();

//将当前线程睡眠,画屏函数工作.
try{
Thread.currentThread().sleep(10);
}catch (Exception e){System.out.println("Exception on sleep");}
}
System.out.println("Threader:"+myName+" has finished the race");
}

}//end class Threader.
//GreatRace.java
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Frame;

public class GreatRace extends java.applet.Applet implements Runnable{
Threader theRacers[];
static int racerCount = 3;
Thread theThreads[];
Thread thisThread;
static boolean inApplet=true;
int numberofThreadsAtStart;

public void init(){
//计算工作线程的个数
numberofThreadsAtStart = Thread.activeCount();
//确定界面的显示风格
setLayout(new GridLayout(racerCount,1));
//确定竞赛者的数量
theRacers = new Threader [racerCount];
theThreads = new Thread[racerCount];
//为每一个竞赛者创建一个线程
for (int x=0;x<racerCount;x++){
theRacers[x]=new Threader ("Racer #"+x);
theRacers[x].setSize(getSize().width,getSize().height/racerCount);
add (theRacers[x]);
theThreads[x]=new Thread(theRacers[x]);

}
}

public void start(){
//启动所有的线程
for (int x=0;x<racerCount;x++)
theThreads[x].start();
//创建一个对照线程
thisThread= new Thread (this);
thisThread.start();
}

public void stop(){
for (int x= 0;x<theRacers.length;x++){
theRacers[x].stop();
}
}

public void run(){
//循环直到结束
while(Thread.activeCount()>numberofThreadsAtStart+2){
try{
thisThread.sleep(100);
} catch (InterruptedException e){
System.out.println("thisThread was interrupted");
}
}

//停止竞赛
if (inApplet){
stop();
destroy();
}
else
System.exit(0);
}

public static void main (String argv[]){
inApplet=false;

//监测在线竞赛者的数量.
if (argv.length>0)
racerCount = Integer.parseInt(argv[0]);

//创建一个新的界面
Frame theFrame = new Frame("The Great Thread Race");
GreatRace theRace = new GreatRace();
theFrame.setSize(400,200);
theFrame.add ("Center",theRace);
theFrame.show();
theRace.init();
theFrame.pack();
theRace.start();
}

}//end class GreatRace.

『玖』 求JAVA源代码

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class GradeStatistic {

public static void main(String[] args) {

GradeStatistic gs = new GradeStatistic();

List<Mark> list = new ArrayList<Mark>();

float sum = 0;

while(true){

Scanner sc = new Scanner(System.in);

System.out.print("Please input student name: ");
String name = sc.nextLine();

if(name.equals("end")){
break;
}

System.out.print("Please input student score: ");
float score = sc.nextFloat();
sum += score;

list.add(gs.new Mark(name, score));

}

float max = list.get(0).getScore();
float min = list.get(0).getScore();

for(Mark mark: list){
if(max < mark.getScore()){
max = mark.getScore();
}

if(min > mark.getScore()){
min = mark.getScore();
}

}

float average = sum / list.size();

System.out.println("Average is: " + average);
System.out.println("Max is: " + max);
System.out.println("Min is: " + min);
}

private class Mark{
private String name;
private float score;

public Mark(String name, float score){
this.name = name;
this.score = score;
}
public String getName() {
return name;
}
public float getScore() {
return score;
}
}
}
----------------------
Please input student name: Zhang san
Please input student score: 100
Please input student name: Li Si
Please input student score: 91
Please input student name: Ec
Please input student score: 35
Please input student name: ma qi
Please input student score: 67
Please input student name: end
Average is: 73.25
Max is: 100.0
Min is: 35.0

『拾』 再哪可以看到java开发项目的整个源代码

打开项目不久看到了嘛

热点内容
收到假eth币 发布:2025-10-20 08:58:16 浏览:973
暗黑破坏神2eth打孔 发布:2025-10-20 08:42:58 浏览:105
BTC和CBT是一样的吗 发布:2025-10-20 08:42:57 浏览:233
华硕trx40Pro供电 发布:2025-10-20 08:33:26 浏览:432
晒人民币编号的朋友圈 发布:2025-10-20 08:25:32 浏览:687
doge格式 发布:2025-10-20 08:02:00 浏览:382
以太坊会爆发吗 发布:2025-10-20 08:01:59 浏览:772
一台比特币矿机的功率 发布:2025-10-20 07:39:24 浏览:925
trx辅助带 发布:2025-10-20 07:35:29 浏览:48
比特币哈希值有多少位 发布:2025-10-20 07:31:20 浏览:633