真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

牛逼的java代碼片段,一段java代碼的詳細解說

50行左右的java程序代碼,要求代碼內(nèi)含有兩個循環(huán),兩個函數(shù),50行,急需

隨便給你寫了一個

目前創(chuàng)新互聯(lián)公司已為近1000家的企業(yè)提供了網(wǎng)站建設、域名、虛擬空間、網(wǎng)站運營、企業(yè)網(wǎng)站設計、廬江網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

package com.wys.util;

import java.util.ArrayList;

import java.util.List;

import java.util.Random;

public class Test {

public static ListInteger smallNumbers,largeNumbers;

public static int sum1 = 0,sum2 = 0;

public static void main(String[] args) {

smallNumbers = new ArrayListInteger();

largeNumbers = new ArrayListInteger();

run();

}

public static void run() {

int i = 0;

for (int j = 0; j 50; j++) {

Random rand = new Random();

i = rand.nextInt(1000);

if (i500) {

small(i);

}else{

large(i);

}

}

System.out.println("隨機輸出的50個數(shù)字中:");

System.out.println("大于500的數(shù)(包括500)共有"+largeNumbers.size()+"個");

System.out.print("他們是"+largeNumbers);

System.out.println();

System.out.println("他們的和是"+sum1);

System.out.println("小于500的數(shù)共有"+smallNumbers.size()+"個");

System.out.print("他們是"+smallNumbers);

System.out.println();

System.out.println("他們的和是"+sum2);

}

private static void large(int number) {

largeNumbers.add(number);

sum1 += number;

}

private static void small(int number) {

smallNumbers.add(number);

sum2 += number;

}

}

求編寫一個超級簡單的Java的程序源代碼

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

class ConstructFrame extends JFrame

{

private static final long serialVersionUID = 1L;

String value1="",result,value2="";

int flag=0,fix=0,sum=1;

Boolean happy;

JTextField text=new JTextField(30);

int flagsum=0;

Container c=getContentPane();

JButton buttonx;

ConstructFrame()

{ super("計算器");

c.setLayout(null);

c.setBackground(Color.blue);

this.setSize(400, 400);

c.add(text);

text.setHorizontalAlignment(JTextField.RIGHT);

final JButton buttonx=new JButton("BackSpace");

c.add(buttonx);

buttonx.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

int count=0;

String temp;

if(flag==0)

{

count=value1.length();

if(count!=1)

temp=value1.substring(0, count-1);

else

temp="0";

value1=temp;

}

else

{

count=value2.length();

if(count!=1)

temp=value2.substring(0, count-1);

else

temp="0";

value2=temp;

}

text.setText(temp);

}

});

final JButton buttony=new JButton("CE");

c.add(buttony);

buttony.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

value1="";

value2="";

flag=0;

text.setText("0");

}

});

final JButton button1=new JButton("1");

c.add(button1);

button1.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+1;

temp=value1;

}

else

{

value2=value2+1;

temp=value2;

}

text.setText(temp);

}

});

final JButton button2=new JButton(" 2 ");

c.add(button2);

button2.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+2;

temp=value1;

}

else

{

value2=value2+2;

temp=value2;

}

text.setText(temp);

}

});

final JButton button3=new JButton("3");

c.add(button3);

button3.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+3;

temp=value1;

}

else

{

value2=value2+3;

temp=value2;

}

text.setText(temp);

}

});

final JButton button4=new JButton("4");

c.add(button4);

button4.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+4;

temp=value1;

}

else

{

value2=value2+4;

temp=value2;

}

text.setText(temp);

}

});

final JButton button5=new JButton("5");

c.add(button5);

button5.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+5;

temp=value1;

}

else

{

value2=value2+5;

temp=value2;

}

text.setText(temp);

}

});

final JButton button6=new JButton("6");

c.add(button6);

button6.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+6;

temp=value1;

}

else

{

value2=value2+6;

temp=value2;

}

text.setText(temp);

}

});

final JButton button7=new JButton("7");

c.add(button7);

button7.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+7;

temp=value1;

}

else

{

value2=value2+7;

temp=value2;

}

text.setText(temp);

}

});

final JButton button8=new JButton("8");

c.add(button8);

button8.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+8;

temp=value1;

}

else

{

value2=value2+8;

temp=value2;

}

text.setText(temp);

}

});

final JButton button9=new JButton("9");

c.add(button9);

button9.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+9;

temp=value1;

}

else

{

value2=value2+9;

temp=value2;

}

text.setText(temp);

}

});

final JButton button0=new JButton("0");

c.add(button0);

button0.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

String temp;

if(flag==0)

{

value1=value1+0;

temp=value1;

}

else

{

value2=value2+0;

temp=value2;

}

text.setText(temp);

}

});

final JButton buttonadd=new JButton(" + ");

c.add(buttonadd);

buttonadd.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

fix=1;

flagsum=0;

}

});

final JButton buttonsubtract=new JButton(" - ");

c.add(buttonsubtract);

buttonsubtract.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

fix=2;

flagsum=0;

}

});

final JButton buttoncheng=new JButton(" * ");

c.add(buttoncheng);

buttoncheng.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

fix=3;

flagsum=0;

}

});

final JButton buttonchu=new JButton(" / ");

c.add(buttonchu);

buttonchu.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

flag=1;

flagsum=0;

fix=4;

}

});

final JButton buttonequal=new JButton(" = ");

c.add(buttonequal);

buttonequal.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{

double temp1,temp2;

double temp=0;

flagsum=0;

temp1=Double.parseDouble(value1);

temp2=Double.parseDouble(value2);

flag=0;

switch(fix)

{

case 1: temp=temp1+temp2;break;

case 2: temp=temp1-temp2;break;

case 3: temp=temp1*temp2;break;

case 4: temp=temp1/temp2;break;

}

result=Double.valueOf(temp).toString();

value1=result;

value2="";

flag=1;

text.setText(result);

}

});

final JButton buttonpoint=new JButton(".");

c.add(buttonpoint);

buttonpoint.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{ if(flagsum==0)

{

String temp;

if(flag==0 )

{

value1=value1+".";

temp=value1;

}

else

{

value2=value2+".";

temp=value2;

}

flagsum=1;

text.setText(temp);

}

}

});

JButton buttonz=new JButton("Start");

c.add(buttonz);

buttonz.addMouseListener(new MouseAdapter()

{

public void mousePressed(MouseEvent e)

{ if(sum%2==1)

{

happy=true;

text.setText("0.");

flag=0;

}

else

{

happy=false;

value1="";

value2="";

text.setText("");

}

text.setEnabled(happy);

button1.setEnabled(happy);

button2.setEnabled(happy);

button3.setEnabled(happy);

button4.setEnabled(happy);

button5.setEnabled(happy);

button6.setEnabled(happy);

button7.setEnabled(happy);

button8.setEnabled(happy);

button9.setEnabled(happy);

button0.setEnabled(happy);

buttonx.setEnabled(happy);

buttony.setEnabled(happy);

buttonadd.setEnabled(happy);

buttonsubtract.setEnabled(happy);

buttonpoint.setEnabled(happy);

buttonequal.setEnabled(happy);

buttoncheng.setEnabled(happy);

buttonchu.setEnabled(happy);

sum++;

}

});

button1.setEnabled(false);

button2.setEnabled(false);

button3.setEnabled(false);

button4.setEnabled(false);

button5.setEnabled(false);

button6.setEnabled(false);

button7.setEnabled(false);

button8.setEnabled(false);

button9.setEnabled(false);

button0.setEnabled(false);

buttonx.setEnabled(false);

buttony.setEnabled(false);

buttonadd.setEnabled(false);

buttonsubtract.setEnabled(false);

buttonpoint.setEnabled(false);

buttonequal.setEnabled(false);

buttoncheng.setEnabled(false);

buttonchu.setEnabled(false);

text.setEnabled(false);

text.setBounds(20, 20, 200, 40);

buttonx.setBounds(20, 60,100, 40);

buttony.setBounds(140, 60,100, 40);

buttonz.setBounds(260, 60,80, 40);

button1.setBounds(20, 120,60, 40);

button2.setBounds(100, 120,60, 40);

button3.setBounds(180, 120,60, 40);

buttonadd.setBounds(260, 120,60, 40);

button4.setBounds(20, 180,60, 40);

button5.setBounds(100, 180,60, 40);

button6.setBounds(180, 180,60, 40);

buttonsubtract.setBounds(260, 180,60, 40);

button7.setBounds(20, 240,60, 40);

button8.setBounds(100, 240,60, 40);

button9.setBounds(180, 240,60, 40);

buttoncheng.setBounds(260,240,60,40);

button0.setBounds(20, 300,60, 40);

buttonpoint.setBounds(100, 300, 60, 40);

buttonequal.setBounds(180,300,60, 40);

buttonchu.setBounds(260, 300,60, 40);

setVisible(true);

}

class MYMouseEvent extends MouseAdapter

{

public void mousePressed(MouseEvent e)

{

value1=e.toString();

text.setText(value1);

}

}

}

class Calutator

{

public static void main(String[] args)

{

new ConstructFrame();

}

}

你自己慢慢的看吧!

java線程的經(jīng)典代碼

package threadgroup;

class ThreadDemo3 extends Thread {

private String name;

private int delay;

public ThreadDemo3(String sname, int i_delay) {

name = sname;

delay = i_delay;

}

public void run() {

try {

sleep(delay);

} catch (InterruptedException e) {

}

System.out.println("多線程測試!\n" + name + "\n" + delay);

}

}

public class testMyThread {

public static void main(String[] args) {

ThreadDemo3 th1,th2,th3;

th1 = new ThreadDemo3("線程1", (int) (Math.random() * 900));

th2 = new ThreadDemo3("線程2", (int) (Math.random() * 900));

th3 = new ThreadDemo3("線程3", (int) (Math.random() * 900));

th1.start();

th2.start();

th3.start();

}

}

package threadgroup;

public class threadDemo {

public static void main(String[] args) {

Thread t = Thread.currentThread();

t.setName("你好嗎?");

System.out.println("正在進行的Thread是:" + t);

try {

for (int i = 0; i 5; i++) {

System.out.println("我不叫穆繼超" + i);

Thread.sleep(3000);

}

} catch (Exception e) {

// TODO: handle exception

System.out.println("Thread has wrong" + e.getMessage());

}

}

}

package threadgroup;

public class threadDemo2 implements Runnable {

public threadDemo2() {

Thread t1 = Thread.currentThread();

t1.setName("第一個主進程");

System.out.println("正在運行" + t1);

Thread t2 = new Thread(this, "");

System.out.println("在創(chuàng)建一個進程");

t2.start();

try {

System.out.println("使他進入第一個睡眠狀態(tài)");

Thread.sleep(2000);

} catch (InterruptedException e) {

System.out.println("Thread has wrong" + e.getMessage());

}

System.out.println("退出第一個進程");

}

public void run() {

try {

for (int i = 0; i 5; i++) {

System.out.println("進程" + i);

Thread.sleep(3000);

}

} catch (InterruptedException e) {

// TODO: handle exception

System.out.println("Thread has wrong" + e.getMessage());

}

System.out.println("退出第二個進程");

}

public static void main(String[] args) {

new threadDemo2();

}

}

給段最簡單的java代碼 讓我新手看一下

最簡單的java代碼肯定就是這個了,如下:

public class MyFirstApp

{

public static void main(String[] args)

{

System.out.print("Hello world");

}

}

“hello world”就是應該是所有學java的新手看的第一個代碼了。如果是零基礎的新手朋友們可以來我們的java實驗班試聽,有免費的試聽課程幫助學習java必備基礎知識,有助教老師為零基礎的人提供個人學習方案,學習完成后有考評團進行專業(yè)測試,幫助測評學員是否適合繼續(xù)學習java,15天內(nèi)免費幫助來報名體驗實驗班的新手快速入門java,更好的學習java!

求這段JAVA程序代碼

//Example.java

class A{

float a;

static float b;

void setA(float a ){

this.a = a;

}

void setB(float b){

this.b = b;

}

float getA() {

return a;

}

float getB() {

return b;

}

void inputA() {

System.out.println(a);

}

static void inputB() {

System.out.println(b);

}

}

public class Example {

public static void main (String args[]){

/*代碼5] //通過類名操作類變量b,并賦值100

[代碼6] //通過類名調(diào)用方法inputB()

A cat=new A();

A dog=new A();

[代碼7] //cat調(diào)用方法setA(int a)將cat的成員a的值設置為200

[代碼8] //cat調(diào)用方法setB(int b)將cat的成員b的值設置為400

[代碼9] //dog調(diào)用方法setA(int a)將dog的成員a的值設置為300

[代碼10] //dog調(diào)用方法setB(int b)將dog的成員b的值設置為800

[代碼11] //cat調(diào)用方法inputA()

[代碼12] //cat調(diào)用方法inputB()

[代碼13] //dog調(diào)用方法inputA()

[代碼14] //dog調(diào)用方法inputB()*/

A.b = 100;

A.inputB();

A cat = new A();

A dog = new A();

cat.setA(200);

cat.setB(300);

dog.setA(300);

dog.setB(800);

cat.inputA();

cat.inputB();

dog.inputA();

dog.inputB();

}

}

有一個要說明的是,setA()與setB()的形參是浮點型的,所以如樓上所說,樓主代碼7到代碼10的形參設錯了。但200,400,300,800是可以的。只是將int改為float.

求一個簡單又有趣的JAVA小游戲代碼

具體如下:

連連看的小源碼

package Lianliankan;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class lianliankan implements ActionListener

{

JFrame mainFrame; //主面板

Container thisContainer;

JPanel centerPanel,southPanel,northPanel; //子面板

JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數(shù)組

JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕

JLabel fractionLable=new JLabel("0"); //分數(shù)標簽

JButton firstButton,secondButton; //

分別記錄兩次62616964757a686964616fe59b9ee7ad9431333335326239被選中的按鈕

int grid[][] = new int[8][7];//儲存游戲按鈕位置

static boolean pressInformation=false; //判斷是否有按鈕被選中

int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標

int i,j,k,n;//消除方法控制

代碼(code)是程序員用開發(fā)工具所支持的語言寫出來的源文件,是一組由字符、符號或信號碼元以離散形式表示信息的明確的規(guī)則體系。

對于字符和Unicode數(shù)據(jù)的位模式的定義,此模式代表特定字母、數(shù)字或符號(例如 0x20 代表一個空格,而 0x74 代表字符“t”)。一些數(shù)據(jù)類型每個字符使用一個字節(jié);每個字節(jié)可以具有 256 個不同的位模式中的一個模式。

在計算機中,字符由不同的位模式(ON 或 OFF)表示。每個字節(jié)有 8 位,這 8 位可以有 256 種不同的 ON 和 OFF 組合模式。對于使用 1 個字節(jié)存儲每個字符的程序,通過給每個位模式指派字符可表示最多 256 個不同的字符。2 個字節(jié)有 16 位,這 16 位可以有 65,536 種唯一的 ON 和 OFF 組合模式。使用 2 個字節(jié)表示每個字符的程序可表示最多 65,536 個字符。

單字節(jié)代碼頁是字符定義,這些字符映射到每個字節(jié)可能有的 256 種位模式中的每一種。代碼頁定義大小寫字符、數(shù)字、符號以及 !、@、#、% 等特殊字符的位模式。每種歐洲語言(如德語和西班牙語)都有各自的單字節(jié)代碼頁。

雖然用于表示 A 到 Z 拉丁字母表字符的位模式在所有的代碼頁中都相同,但用于表示重音字符(如"é"和"á")的位模式在不同的代碼頁中卻不同。如果在運行不同代碼頁的計算機間交換數(shù)據(jù),必須將所有字符數(shù)據(jù)由發(fā)送計算機的代碼頁轉(zhuǎn)換為接收計算機的代碼頁。如果源數(shù)據(jù)中的擴展字符在接收計算機的代碼頁中未定義,那么數(shù)據(jù)將丟失。

如果某個數(shù)據(jù)庫為來自許多不同國家的客戶端提供服務,則很難為該數(shù)據(jù)庫選擇這樣一種代碼頁,使其包括所有客戶端計算機所需的全部擴展字符。而且,在代碼頁間不停地轉(zhuǎn)換需要花費大量的處理時間。


當前題目:牛逼的java代碼片段,一段java代碼的詳細解說
標題網(wǎng)址:http://weahome.cn/article/hohdeo.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部