请高手解释以下这段java代码的意思,感谢!

来源:百度知道 编辑:UC知道 时间:2024/05/16 14:05:01
package trans;

import java.net.*;
import javax.swing.*;
public class BroadCast implements Runnable
{
private InetAddress address;
private char op;
private String mes;
public BroadCast(char op,InetAddress address,String mes)
{
this.address = address;
this.op = op;
this.mes = mes;
}
public void run()
{
String newStr = "";
if(op == 'S' || op == 'R' || op == 'M' || op == 'A')
{
newStr += op;
newStr += mes;
}
else
{
JOptionPane.showMessageDialog(null,"无该操作!","错误", JOptionPane.ERROR_MESSAGE);
return;
}
try{

import java.net.*;
import javax.swing.*;
public class BroadCast implements Runnable//继承自Runnable
{
private InetAddress address;//定义一个对象变量,inetaddress 私有类型
private char op;//定义一个char类型私有变量 op
private String mes;//定义一个string类型变量 mes
public BroadCast(char op,InetAddress address,String mes)//编写构造函数,带参数,
{
this.address = address;
this.op = op;
this.mes = mes;
}
public void run()//开始函数
{
String newStr = "";//定义空string类型变量newstr
if(op == 'S' || op == 'R' || op == 'M' || op == 'A')//如果op=S 或者op=R 或者 op=M 或者op=A时
{
newStr += op;
newStr += mes;//前面定义的string变量就+op+mes的值
}

else //如果不符合上面条件的话
{
JOptionPane.sho