第一個(gè):
成都創(chuàng)新互聯(lián)公司專(zhuān)注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、西工網(wǎng)絡(luò)推廣、成都小程序開(kāi)發(fā)、西工網(wǎng)絡(luò)營(yíng)銷(xiāo)、西工企業(yè)策劃、西工品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供西工建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com
import?java.util.Scanner;
/**
*?@author?zhangdong
*?@date?2018/4/24??16:14
*/
public?class?HomeWork1?{
public?static?void?main(String[]?args)?{
System.out.println("請(qǐng)輸入一個(gè)數(shù)字(0-3)");
Scanner?scanner?=?new?Scanner(System.in);
int?num?=?scanner.nextInt();
switch?(num)?{
case?0:
System.out.println("0-?明天去打球");
break;
case?1:
System.out.println("1-?明天去跑步");
break;
case?2:
System.out.println("2-?明天去放鴨");
break;
case?3:
System.out.println("3-?明天去爬山");
break;
default:
System.out.println("其他-明天呆在家里");
break;
}
}
}
第二個(gè):
import?java.util.Scanner;
/**
*?@author?zhangdong
*?@date?2018/4/24??16:18
*/
public?class?HomeWork2?{
public?static?void?main(String[]?args)?{
System.out.println("請(qǐng)輸入一個(gè)數(shù)字(1-7)");
Scanner?scanner?=?new?Scanner(System.in);
int?num?=?scanner.nextInt();
switch?(num)?{
case?1:
System.out.println("星期一");
break;
case?2:
System.out.println("星期二");
break;
case?3:
System.out.println("星期三");
break;
case?4:
System.out.println("星期四");
break;
case?5:
System.out.println("星期五");
break;
case?6:
System.out.println("星期六");
break;
case?7:
System.out.println("星期日");
break;
default:
System.out.println("輸入錯(cuò)誤!");
break;
}
}
}
第三個(gè):
/**
*?@author?zhangdong
*?@date?2018/4/24??16:20
*/
public?class?Car?{
private?String?name;
private?String?color;
private?String?placeOrigin;
public?Car(String?name,?String?color,?String?placeOrigin)?{
this.name?=?name;
this.color?=?color;
this.placeOrigin?=?placeOrigin;
}
public?String?getName()?{
return?name;
}
public?void?setName(String?name)?{
this.name?=?name;
}
public?String?getColor()?{
return?color;
}
public?void?setColor(String?color)?{
this.color?=?color;
}
public?String?getPlaceOrigin()?{
return?placeOrigin;
}
public?void?setPlaceOrigin(String?placeOrigin)?{
this.placeOrigin?=?placeOrigin;
}
public?void?run()?{
System.out.println("汽車(chē)正在以50km/s的速度行駛中");
}
public?void?run(int?speed)?{
System.out.println("汽車(chē)正在以"?+?speed?+?"km/s的速度行駛中");
}
@Override
public?String?toString()?{
return?"汽車(chē)基本信息:"?+
"???車(chē)名:'"?+?name?+?'\''?+
"???顏色:'"?+?color?+?'\''?+
"???產(chǎn)地:'"?+?placeOrigin?+?'\''?+
'}';
}
public?static?void?main(String[]?args)?{
Car?car?=?new?Car("法拉利",?"黑色",?"德國(guó)");
System.out.println(car.toString());
car.run();
car.run(80);
}
}
import java.util.*;
public class Test {
public static void main(String[] args){
System.out.println("您的性別是:\n1.男\(zhòng)n2.女\n請(qǐng)根據(jù)具體情況選擇編號(hào):");
Scanner sc=new Scanner(System.in);
int sex=sc.nextInt();
switch(sex){
case 1:System.out.println("您選擇的性別是男人");
break;
case 2:System.out.println("您選擇的性別是女人");
break;
default:System.out.println("數(shù)據(jù)非法!");
break;
}
}
}
工程自己建,然后你建個(gè)Test類(lèi)把代碼復(fù)制進(jìn)去就行了。
public?class?Test?{
public?static?void?main(String[]?args)?{
//?定義數(shù)組
int[][]?array?=?new?int[5][6];
//?生成隨機(jī)數(shù)初始化數(shù)組
for?(int?i?=?0;?i??array.length;?i++)?{
for?(int?j?=?0;?j??array[i].length;?j++)?{
array[i][j]?=?(int)?(40?*?Math.random())?+?10;
}
}
//?輸出數(shù)組
for?(int?i?=?0;?i??array.length;?i++)?{
for?(int?j?=?0;?j??array[i].length;?j++)?{
System.out.print(array[i][j]?+?"\t");
}
System.out.println();?//?換行
}
}
}
package Test1;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.IntSummaryStatistics;
import java.util.Scanner;
import java.util.Vector;
public class D {
static String s1 = "";
public static void main(String[] args) {
int day = LocalDateTime.now().getDayOfMonth();
Month month = LocalDateTime.now().getMonth();
int i = 1, i1 = 0;
VectorInteger vector=new Vector();
Scanner scanner = new Scanner(System.in);
while (i day + 1) {
System.out.println("請(qǐng)輸入" + month + "月" + i + "日走的步數(shù)");
try {
i1 = scanner.nextInt();
} catch (Exception e) {
// TODO: handle exception
System.out.println("輸入錯(cuò)誤,請(qǐng)重新輸入");
continue;
}
vector.add(i1);
i++;
}
scanner.close();
IntSummaryStatistics intSummaryStatistics=vector.stream().mapToInt(x-x).summaryStatistics();
int i2=intSummaryStatistics.getMax();
int i3=vector.indexOf(i2);
System.out.println(month+"月走的步數(shù)最多的日期為: "+(i3+1)+"號(hào)");
System.out.println("最多的步數(shù)為: "+i2);
}
}
package com.zpp;public class Charge {
public static void main(String [] args) {
if(args.length ==0) {
System.out.println("parameter error!");
System.out.println("java com.zpp.Charge [int]");
return;
}
int min = Integer.parseInt(args[0]);
double money = 0.0;
if (min = 0) {
money =0.0;
System.out.println("not money");
} else if (min = 60) {
money = 2.0;
} else {
money = 2.0 + (min - 60) * 0.01;
}
System.out.println("please pay: " + money);
}
} 編譯:javac -d . Charge.java運(yùn)行:java com.zpp.Charge 111
最簡(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ǔ)的新手朋友們可以來(lái)我們的java實(shí)驗(yàn)班試聽(tīng),有免費(fèi)的試聽(tīng)課程幫助學(xué)習(xí)java必備基礎(chǔ)知識(shí),有助教老師為零基礎(chǔ)的人提供個(gè)人學(xué)習(xí)方案,學(xué)習(xí)完成后有考評(píng)團(tuán)進(jìn)行專(zhuān)業(yè)測(cè)試,幫助測(cè)評(píng)學(xué)員是否適合繼續(xù)學(xué)習(xí)java,15天內(nèi)免費(fèi)幫助來(lái)報(bào)名體驗(yàn)實(shí)驗(yàn)班的新手快速入門(mén)java,更好的學(xué)習(xí)java!