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

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

java新手代碼大全簡(jiǎn)單 java新手代碼大全實(shí)例

java新手,求完整的源代碼

//都是從新手過來的,以下代碼供參考

成都創(chuàng)新互聯(lián)公司于2013年創(chuàng)立,先為蓬溪等服務(wù)建站,蓬溪等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為蓬溪企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

//1.

public?class?BankAccount?{

private?static?String?acctnum;

private?static?double?money;

private?static?void?showAcct()?{

System.out.println("賬號(hào)為:?"?+?acctnum);

}

private?static?void?showMoney()?{

System.out.println("余額為:?"?+?money);

}

public?BankAccount(String?acc,?double?m)?{

this.acctnum?=?acc;

this.money?=?m;

}

public?static?void?main(String[]?args)?{

BankAccount?ba?=?new?BankAccount("626600018888",?5000.00);

ba.showAcct();

ba.showMoney();

}

}

//2.

public?class?Triangle?{

private?static?float?a;

private?static?float?b;

private?static?float?c;

public?Triangle(float?a,?float?b,?float?c)?{

this.a?=?a;

this.b?=?b;

this.c?=?c;

}

public?static?boolean?judgeTriangle(float?a,?float?b,?float?c)?{

if?((a??Math.abs(b?-?c)??a??b?+?c)

?(b??Math.abs(a?-?c)??b??a?+?c)

?(c??Math.abs(a?-?b)??c??a?+?b))

return?true;

else

return?false;

}

public?float?getCircumference()?{

return?this.a?+?this.b?+?this.c;

}

}

//3.

public?class?TestTriangle?{

public?static?void?main(String[]?args)?{

Triangle?t?=?new?Triangle(5.3f,7.8f,9.3f);

if(t.judgeTriangle(5.3f,7.8f,9.3f)){

System.out.print("能夠成三角形,周長(zhǎng)為:?");

System.out.printf("%9.2f",t.getCircumference());}

else

System.out.println("不能構(gòu)成三角形");

}

}

各位大神,Java新手,以下代碼幫看看,謝謝

add(new JLabel(lightIcon));

add(new JLabel(roomIcon));

這個(gè)里面?zhèn)鞯膮?shù)不對(duì),你看看文檔

JAVA編程 新手,寫簡(jiǎn)單點(diǎn)

public?static?void?main(String[]?args)?{

//控制臺(tái)輸入

Scanner?scan?=?new?Scanner(System.in);

//三次機(jī)會(huì)

for?(int?i?=?2;?i?=?0;?i--)?{

//提示用戶輸入

System.out.println("請(qǐng)輸入用戶名");

//用戶名

String?userName?=?scan.next();

//提示用戶輸入

System.out.println("請(qǐng)輸入密碼");

//密碼

String?password?=?scan.next();

//如果輸入正確,??break,結(jié)束循環(huán)

if("jim".equals(userName)??"123456".equals(password))?{

System.out.println("歡迎登錄MyShopping系統(tǒng)");

break;

}

else?{

if(i??0)?{

System.out.println("密碼錯(cuò)誤,你還有"+i+"次機(jī)會(huì)!");

continue;

}

if(i?==?0)?{

System.out.println("密碼錯(cuò)誤,三次機(jī)會(huì)已用完!");

}

}

}

}

求一個(gè)簡(jiǎn)單java程序代碼,謝謝

public class TestStar {

public static void main(String[] args) {

String star = "*";

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

if (i == 0) {

System.out.print(" " + star);

System.out.println();

}

if (i == 1) {

for (int z = 0; z 4; z++) {

System.out.print(" " + star);

}

System.out.println();

}

if (i == 2) {

System.out.print(" ");

for (int x = 0; x 3; x++) {

System.out.print(" " + star);

}

System.out.println();

}

if (i == 3) {

for (int y = 0; y 2; y++) {

System.out.print(" " + star + " ");

}

}

}

}

}

是好使的 但是我沒找到畫五角星有什么規(guī)律(五角星好象不是正規(guī)圖形吧?)如果還有什么要求的話 補(bǔ)充問題(如果是用*填充所有的東西 不包括 “ ”的話 我可以重新再給你寫一個(gè))

給段最簡(jiǎn)單的java代碼 讓我新手看一下

最簡(jiǎn)單的java代碼肯定就是這個(gè)了,如下:

public class MyFirstApp

{

public static void main(String[] args)

{

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

}

}

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

求一Java代碼,要簡(jiǎn)單的。大概一百多行的的。

題目:一球從100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地時(shí),共經(jīng)過多少米?第10次反彈多高?

這個(gè)題目,下面我會(huì)貼出來兩種代碼。其實(shí)這個(gè)題目,我煩了簡(jiǎn)單計(jì)算,想搞得有趣味性一點(diǎn),結(jié)果耽誤了好幾天時(shí)間,最后發(fā)現(xiàn)搞的也不好。

先第一種,為了解題而解題。

==== Main.java ====

public class Main {

private double TotalHeight = 100;

private double CurHeight = 50;

public void drop(int times) {

if ((times - 1) == 0) {

return;

}

setTotalHeight(getTotalHeight() + 2 * getCurHeight());

setCurHeight(getCurHeight() / 2);

drop(times - 1);

}

public double getTotalHeight() {

return TotalHeight;

}

public void setTotalHeight(double totalHeight) {

TotalHeight = totalHeight;

}

public double getCurHeight() {

return CurHeight;

}

public void setCurHeight(double curHeight) {

CurHeight = curHeight;

}

public static void main(String[] args) {

Main main = new Main();

main.drop(2);

System.out.println("Total height is " +

main.getTotalHeight());

System.out.println("Current height is " +

main.getCurHeight());

}

}

==== 然后是第二種 =====

==== Main.java ====

package main;

import javax.swing.JFrame;

import panel.BallPanel;

import time.Delay;

public class MainFrame extends JFrame {

public MainFrame(String title) {

super(title);

}

public static void main(String[] args) {

Delay delay = new Delay();

MainFrame frame = new MainFrame("Hello JFrame");

BallPanel ballPanel = new BallPanel();

frame.add(ballPanel);

frame.setSize(500, 500);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

delay.initDelay();

ballPanel.setDelay(delay.getDelay());

ballPanel.loopDrop(0);

}

}

==== Delay.java ====

package time;

public class Delay {

public void initDelay() {

int g = 10;

int i = 0;

double s, t, t0 = 0.0;

delay = new int[100];

for (s = 100; s 10100; s += 100) {

t = Math.sqrt(2 * s / g);

delay[i++] = (int) ((t - t0) * 100);

t0 = t;

}

}

public int[] getDelay() {

return delay;

}

private int delay[];

}

==== BallPanel.java ====

package panel;

import java.awt.Color;

import java.awt.Graphics;

import javax.swing.JPanel;

public class BallPanel extends JPanel {

public BallPanel() {

super();

}

public void paint(Graphics g) {

g.clearRect(0, 0, this.getWidth(), this.getHeight());

g.setColor(Color.BLUE);

g.fillOval(250, ballCenter, 30, 30);

}

public void loopDrop(int height) {

int i;

if (this.height == height) { // At bottom

for (i = 0; i targetHeight; i += MUL) {

ballCenter = this.height - i;

this.repaint();

try {

Thread.sleep(delay[(targetHeight - i - 1) / MUL]);

} catch (InterruptedException e) {

e.printStackTrace();

}

}

loopDrop(this.height - i);

} else { // At top

for (i = height; i this.height; i += MUL) {

ballCenter = i;

this.repaint();

try {

Thread.sleep(delay[(i - height) / MUL]);

} catch (InterruptedException e) {

e.printStackTrace();

}

}

targetHeightV = targetHeightV / 2;

targetHeight = targetHeightV;

if (targetHeight != 0) {

loopDrop(i);

}

}

}

public void setDelay(int delay[]) {

this.delay = delay;

}

private int extracted() {

return 100 * MUL;

}

private int targetHeight = extracted();

private int targetHeightV = extracted();

private int ballCenter = 0;

private int height = extracted();

private int delay[];

private final int MUL = 4;

}

其實(shí)所謂的第二種,是用的JFrame在JPanel上畫圖,直觀的展示出來每次彈起來的效果。因?yàn)?00像素實(shí)在太小了,所以我做了一個(gè)變量MUL,相

當(dāng)于是等比例擴(kuò)大的效果。問題就是彈不到10次距離就用光了,所以。。。。。權(quán)當(dāng)娛樂了。。當(dāng)然可以等比例在放大,例如100M看成是10000像素,這

樣能多彈幾次。這個(gè)程序,最后球就在那里不動(dòng)了,程序不會(huì)自己退出。


網(wǎng)站欄目:java新手代碼大全簡(jiǎn)單 java新手代碼大全實(shí)例
網(wǎng)頁路徑:http://weahome.cn/article/hpjepj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部