来源:蜘蛛抓取(WebSpider)
时间:2015-04-11 00:35
标签:
java二维码生成代码
求一个JAVA编的聊天小程序。_百度知道
求一个JAVA编的聊天小程序。
我刚学JAVA,哪位高手给我个简单(超简单)的聊天程序让我学习下?
提问者采纳
return l.println(l);D
return i.println(".io.net.out.
s = ".write((str+".add(BorderL public GetMessage(JTextArea context, port). } public static Map p(Map l) {
return O; } public static List p(List l) {
} catch (IOException e) {
e.".getOutputStream().println(O; /.add(sp): O) {
return l.out.getBytes()).
return l.println(O.getContentPane().聊天室服务器端逻辑/.Entry p(M
S } public static HashSet p(HashSet l) {
System,Socket s){
this.println(l).out./().getLocalHost().setResizable(false).;
this.1".print(".printStackTrace();
c.context=
} catch (IOException e) {
e.println(i);
JPanel p = new JPanel().out.io.\
new Client(strIP.readLine();IP协议;import java.&Socket&
server, 10);
} catch (UnknownHostException e) {
} catch (IOException e) {
e.getInputStream())).println(l).Entry p(M } public static LinkedList p(LinkedList l) {
System.getOutputStream(); } public static TreeSet p(TreeSet l) {
System.print(o.println(l).s=s.toString());
say.setText(".out.setSize(300;
this.println(l);
} catch (UnknownHostException e) {
return l,& } public static Set p(Set l) {
} }}/.getText().聊天室客户端逻辑/\.
return i.setLayout(new BorderLayout()).*;/.*;GetM public List&
}); li= } public static Object[] p(Object[] O) {
S.start().println(l); public Client(SSimport java.out.close(););
return l.println(l); } public static long p(long i) {
String s = &
s = ss.getLi().client=client.*; }}/ public Service(S
} }}/. } public static long p(long i) {
System.Entry l) {
System.println(l).SOUTH;
String c=/.getHostAddress();
}catch (IOException e) {
strIP = InetAddress.event, int port) {
c = } public void run(){
BufferedReader br=new BufferedReader(new InputStreamReader(s;
} catch (IOException e) {Service.print(&
return l.*; } public static TreeSet p(TreeSet l) {
S); } public static ArrayList p(ArrayList l) {
S private int port = 0.add(s). } public static int p(int i) {
S } public static List p(List l) {
System, say);[&public class Client extends JFrame { private String ip = ".
return l.java);public class Debug { public static String p(String s) {
System.println(l);;public class Service extends Thread{ private Socket client=null.).println(s);
send(str + &import java,s);
return i.*.".println(".printStackTrace();import java.*.printStackTrace().awt.getText().isClosed() && c.println(s);
for (Opublic class Debug { public static String p(String s) {
Sn".println(l); li=new ArrayList<.swing.println(i).print(s). } public static Object[] p(Object[] O) {
S } public static HashMap p(HashMap l) {
S } public static void main(String[] args) {
String strIP =
return l.out.println(l).out.java } public static Object p(Object O) {
SDebug, 8888).
} } public static void main(String[] args) {
new Server(8888);
} } public void start(){
while(true){
Socket s.addActionListener(new ActionListener() {
private void send(String str) {
OutputStream os = s.printStackTrace().; } public void run(){
BufferedReader br=new BufferedReader(new InputStreamReader( } public static LinkedHashSet p(LinkedHashSet l) {
System.out.start():16;
List&+str).out.toString().*.getLi();
li.io.out.setVisible(true); private JTextArea context = new JTextArea(10.add(BorderLayout,Socket client){
say.println(l).0;
s = ".printStackTrace().isConnected()){
OutputStream os=c.java private ServerSocket ss= getLi(){
return li.setEditable(false).*.CENTER.println(l).out.println(l);
while(true){
String str=
String s = &import java.out,&
public void actionPerformed(ActionEvent arg0) {
String str = say.write(str. } public static Object p(Object O) {
System.toString()); } public static Map.java private JTextField say = new JTextField(10).]&/.println(l););".javaSocket>以下基于TCP/.server=server.out.printStackTrace();
System.Entry l) {
System.println(l).start().
context.println(l).toString());/.println(l).remove(client); } public static LinkedHashSet p(LinkedHashSet l) {
System. private C127.print(o. private Server server=null. } public static M } public static HashMap p(HashMap l) {
System.javaimport java, 300););.out. }}/.printStackTrace(); } public static HashSet p(HashSet l) {
return l, s).public class GetMessage extends Thread{ private JTextArea context=public class Server { private List<, p);&[".setText(c+& }}17!c.getInputStream()));
new Service(this.printStackTrace();Socket&
new GetMessage( } public static Map p(Map l) {
return l.print(s).out.*;n& } public Server(int port){
ss=new ServerSocket(port); } public static ArrayList p(ArrayList l) {
S } public static Set p(Set l) {
System.println(l); private Socket s=null.*.println(i);
s = new Socket(ip.*.*.println(l); } public static int p(int i) {
for (Object o .toString()); private Socket s =
while(true){
String str=br.*.readLine(); JScrollPane sp = new JScrollPane(context):li){
if(;/.*.getBytes());n& } public static LinkedList p(LinkedList l) {
} catch (IOException e) {);]".io.out.*;: O) {
os.println(i)
其他类似问题
31人觉得有用
您可能关注的推广
小程序的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁求编写一个java程序_百度知道
求编写一个java程序
售票中心分配一定数量的票、SealWindow、售票中心,利用你所学的线程知识来模拟此售票过程、TicketSealCenter分别代表票信息编写三各类Ticket,由若干个售票窗口进行出售、售票窗口
提问者采纳
}}class Ticket implements Runnable/
catch (Exception e)
t;/.class)
/.sleep(10);
catch (Exception e)
Sclass TicketSealCenter{ int number:&synchronized (this)
synchronized (T TicketSealCenter(int number) {
this.start().getName()+".number).currentThread();
Thread t2 = new Thread(t)t3;Thread t3 = new Thread(t); boolean flag =
Thread t1 = new Thread(t); sale.start();
Thread.number--.number);extends Thread{ public
static TicketSealCenter tc = new TicketSealCenter(100).start();
while (true)
show();/.number>.currentThread();Thread t4 = new Thread(t).start();0)
Thread./.number --.flag = false.number& public void run() {
{ while(true)
/:".println(Thread.println(Tt4.sleep(10);0)
T/+/.getName()+&
t1.sleep(10);
catch (Exception e)
} } public static synchronized void show() {
} }}public class
SealWindow{ public static void main(String[] args)
Ticket t = new Ticket();/.number = number
提问者评价
其他类似问题
}catch(Exception e){
e.start();售票&0){
System.println(Thread.getName()+&
new Thread(s1);
new Thread(s2).start();
public void run(){
while(ticket&+ticket--)class TicketConsumer implements Runnable{
static int ticket = 20.currentThread();
TicketConsumer s2 = new TicketConsumer().start();
}}public class TestTicket{
public static void main(String[]args)throws Exception{
TicketConsumer s1 = new TicketConsumer();
new Thread(s3);
TicketConsumer s3 = new TicketConsumer().printStackTrace().sleep(1000).out
java程序的相关知识
按默认排序
其他1条回答
票信息、售票窗口、售票中心。
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁求写一个简单的JAVA程序_java吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:239,024贴子:
求写一个简单的JAVA程序收藏
两个线程同时操作一个串对象线程1: 对这个串的尾部不断增加字母'a'线程2: 从这个串的尾部不断删除字母'a'每个线程不间断地执行1000次。 --------------------------------------single dog single dog,single all the way.online game,masturbate,why not be a gay?Hey!single dog single dog,single all the way.no more wait,no more hate,let us all be gay!
我去,不知不觉唱出来了~
字符串尾部的a不够减怎么办
--------------------------------------single dog single dog,single all the way.online game,masturbate,why not be a gay?Hey!single dog single dog,single all the way.no more wait,no more hate,let us all be gay!
我在网上找了一个代码改了改,但是貌似不对。。 --------------------------------------single dog single dog,single all the way.online game,masturbate,why not be a gay?Hey!single dog single dog,single all the way.no more wait,no more hate,let us all be gay!
public class Test6 implements Runnable{
private static Object lock=new Object();
private static int flag=1;
private static String str=&&;
public static void setStr(String s){
public Test6(){
tflag=flag++;
public void run(){
int i=1000;
while(true){
synchronized(lock){
flag=flag&2?1:
if(tflag==flag){
if(flag==1){ str+=&a&; }else {
str=str.substring(0,str.length()-1); } flag++;
System.out.println(Thread.currentThread().getName()+& &+str);
public static void main(String[] args){
Test6.setStr(&Hello World &);
Thread t1=new Thread(new Test6(),&线程1&);
Thread t2=new Thread(new Test6(),&线程2&);
t1.start();
t2.start();
少年,我看你根骨奇佳,拜我为师可好?为师教你杀伐之术。
也是醉了。首先,这涉及到多线程共享同一个作用变量的问题。其次,涉及到多线程同时“操作”共享变量问题。。。。1,实现runable接口,实例化一个线程对象。启动两个线程罢了。2.操作变量方法,需要同步锁。这个连最基本的多线程demo都算不上
话说楼主不是c吧基佬么
StringB楼主ID萌翻人家了,好羞涩;
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或求JAVA编写的 简易计算器程序,附上注释_百度知道
求JAVA编写的 简易计算器程序,附上注释
最好有注释的,并且可以清零的, 求一个简易计算器程序
实现简单的加减乘除 (可以计算小数点)本人初学JAVA对于JAVA界面编程不太熟悉
设置off键;/背景色pn2;);/pn1;b = new JButton(&),&/);).setHorizontalAlignment(JTextF/.equals(".equals(&add butten 1b;add butten 2b;=&加法运算else if(s.setForeground(Color.add(b);/););pn1.add(b);2&/b = new JButton(".North".).equals(&)&&.add(b)!command.setToolTipText(".add(pn2;*&add button -b!command.JTextField tf = new JTextField();Error&设置为可视}//\//pn3;);)) /.*;add butten 3b;",s1;add button 7b.getText()+d1);pn1;+",".setToolTipText(&/.exit(0);add butten +b;设置按钮JButton b = new JButton(&/pn1;);{s = command.setBackground(C/b = new JButton(&/设置字体颜色b;//.addActionListener(this);-&\pn1;/pn1;);add button 9b;c.add(b);East&);/.add(b);add button 8b;/Error&设置字体颜色b;)) d1 = d1+d2;OFF&*".equals(&//d1 = new Double(s1).BLUE);/记录输入值的变量清空}else if(清零键 按下时返回初始状态{s1=除法运算}catch(Exception ex){4&JPanel pn3 = new JPanel(new BorderLayout());运算界面pn1;9&//public class Calculator implements ActionListener{String s=&JPanel pn1 = new JPanel();处理按钮按下时的动作;/.&//add button =b,d2!&b = new JButton(&public void init()/OFF&pn1.*.setForeground(Color,&import java.equals(&d1;//设置字体颜色b;if();pn1;/.equals(&/".equals(&add button \.add(b;/)) d1 = d2-d1;/.addActionListener(this);CLEAR".addActionListener(this);))/.getActionCommand();乘法运算else if(s;7&-".equals(&//)&&;/&);设置字体颜色b;///)) d1 = d1*d2;add button 6b;/.getText()+command);b.RED);/pn1;b = new JButton(&pn1;pn1;b = new JButton(&".BLUE).addActionListener(this);/);););pn1;减法运算else if(s;add button 0b;b = new JButton(&pn1;pn1;add butten 5b.add(tf.RED).setForeground(C/.doubleValue();请按退出键;///.add(b);CLEAR".getContentPane().addActionListener(this);pn1;/b;设置清零键b;6".setLayout(new GridLayout(4;/.addActionListener(this);//.add(b);b = new JButton(&b = new JButton(".RIGHT);+".*;)./*&pn1;JPanel pn2 = new JPanel();5&)&&;0".equals(&) .add(b);/Center".add(b).equals(&设置大小设置字体颜色b;请按清除键;);).ORANGE).setForeground(C)) Ss1 =double d1;设置字体颜色b;/小计算器by Graduate&b = new JButton(&错误显示".addActionListener(this);/,还原输入数字try{if(s;/.addActionListener(this);//,.equals(&);//,点击退出应用程序b;/Center"!/.event!);/,300);S+&/.RED).add(b.add(b);/!command.setText(&\\///)&&,进行相应的处理public void actionPerformed(ActionEvent e){String command =//.add(pn3.equals(&);JFrame jf = new JFrame(&/)!command,显示运算结果{tf.setVisible(true);))d1 = d2/b;/.add(b);b = new JButton(".setForeground(Cb = new JButton(&判断输入是否为+ - * \.setText(".add(b);设置背景色b;/功能键界面(清除键和关闭键)pn2;);&;//=&;;add butten 4b;/s=".addActionListener(this);b = new JButton(".addActionListener(this);//,&判断输入是否为数字{if(s1==null)/pn2.add(b);}} 还是不会的话加我b = new JButton(".BLUE);}}else if(.add(b);/字符串型转换为双精度型.addActionListener(this).addActionListener(this);b = new JButton(&输入=时;/.addActionListener(this);实现计算器界面{Container c=jf.getMessage());),".addActionListener(this);North&/d2 = d1;&add button *b;\//.add(b);8".setForeground(Ctf.addActionListener(this);//.addActionListener(this).setLayout(new BorderLayout()).setBackground(Cb;b = new JButton(".setForeground(C)) /-&文本框c;判断输入是否为第一个s1 =off键 关闭应用程序else if(;字体颜色b,4));}else/.addActionListener(this)!&/3&).add(pn1);pn3import javax.setSize(300;/);\/b = new JButton(&1&=".add(b);/.addActionListener(this).init();else s1+=command.BLUE).b;}}public static void main(String [] args){new Calculator().setText(/.println(ex.setText(tf.YELLOW);/
其他类似问题
简易计算器的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁求写个java小程序_百度知道
求写个java小程序
c,统计每个字符出现的次数并输出题目是这样的:把当前文件中的所有文本拷贝:
a,存入一个txt文件,::
当: 15 次
提问者采纳
close().toCharArray():
a!= null) {
sb,存入一个txt文件;
StringBuffer sbres=new StringBuffer(".append(str+&
for(int i=0.FileR
char[] a=次&&j++){
if(a[i]==a[j]) k++;a;读字符流
String fileName = &a;;c;1;
把当前文件中的所有文本拷贝;
BufferedReader br = new BufferedReader(fr);n&0){
String str=a[i]+".valueOf(a[i]))<,统计每个字符出现的次数并输出;
while ((nextLine = br:/.c.println(str);
BufferedWriter bwres = new BufferedWriter(frres):
b.toString().io.BufferedWriter:
cimport java.toString());/;
bwres.close().BufferedReader:;
FileReader fr = new FileReader(fileName).txt".j&i++){
int k=0;);
public static void main(String[] args) throws IOException {
/.readLine()) .append(nextLine)://.write(public final class Second {
/.txt".close(); /,并追加到StringBuffer中
StringBuffer sb=new StringBuffer(&);
fr: 15 次
*/写字符流
String fileNameres = ":".io.io.indexOf(S\+k+".FileWi<.length.IOException.toString(),例如;取出文本中所有行;
for(int j=0;2;;
FileWriter frres = new FileWriter(fileNameres);
String nextL
bwres.close().io
提问者评价
其他类似问题
31人觉得有用
小程序的相关知识
按默认排序
其他2条回答
统计a-z字符或0-9数字等字符还行,统计汉字的话,你想想要定义多少个变量啊上千个?
真个不是很难啊,应该baidu上面有啊,以前做过,现在忘了啊
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁