評論
# re: java在線編譯器-youjavait.com [未登錄] 2011-12-29 19:23 z
class test{
static int x=5;
static{x+=10;}
public static viod main (String args[]){
System.out.println('x='+x)
}
statilc{x=x-5;}
} 回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2012-05-28 17:01 aa
public static int mcCarthy(int n) {
if (n > 100) return n - 10;
else return mcCarthy(mcCarthy(n+11));
}
回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2012-08-11 07:22 123
# re: java在線編譯器-youjavait.com 2013-01-20 22:29 hualngyiying
# re: java在線編譯器-youjavait.com 2013-01-21 16:43 hualngyiying
//需求:用switch語句實現四季的選擇
class SwitchDemo
{
public static void main(String[] args)
{
int i=7;
switch (i)
{
case 3:
case 4:
case 5:
System.out.println(i+"春季");
break;
case 6:
case 7:
case 8:
System.out.println(i+"夏季");
break;
case 9:
case 10:
case 11:
System.out.println(i+"秋季");
break;
case 12:
case 1:
case 2:
System.out.println(i+"冬季");
}
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2013-08-06 14:49 nnn
class test{
String s = "Hello";
public static viod main (String args[]){
String[] str = s.split("A");
System.out.println(str);
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2013-09-04 19:27 啊
class SwitchDemo
{
public static void main(String[] args)
{
int i=7;
switch (i)
{
case 3:
case 4:
case 5:
System.out.println(i+"春季");
break;
case 6:
case 7:
case 8:
System.out.println(i+"夏季");
break;
case 9:
case 10:
case 11:
System.out.println(i+"秋季");
break;
case 12:
case 1:
case 2:
System.out.println(i+"冬季");
}
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2013-10-12 08:25 i
# re: java在線編譯器-youjavait.com 2013-10-12 08:25 i
class SwitchDemo
{
public static void main(String[] args)
{
int i=7;
switch (i)
{
case 3:
case 4:
case 5:
System.out.println(i+"春季");
break;
case 6:
case 7:
case 8:
System.out.println(i+"夏季");
break;
case 9:
case 10:
case 11:
System.out.println(i+"秋季");
break;
case 12:
case 1:
case 2:
System.out.println(i+"冬季");
}
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2013-11-21 21:47 lk
修改JEMail應用程序包括一個明確的按鈕,用戶可以單擊隨時清除“;”、“主題;”、“消息;”字段。保存文件為JEMail2.java 回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2013-12-29 14:41 123
public class Test{
publilc static void main(String[] args){
System.out.print("i love you");
}
}
回復 更多評論
# re: java在線編譯器-youjavait.com 2014-01-02 13:18 阿
class A{
public static int a1;
public int a2;
}
public class Test{
public static void main(String[] args){
A t1=new A();
t1.a1=4;
t1.a2=5;
A t2=new A();
t2.a1=6;
t2.a2=7;
System.out.println(t1.a1+","+t1.a2);
System.out.println(t2.a1+","+t2.a2);
}
}
回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2014-03-18 20:11 1
public class Main {
System.out.println("######## ## ## ## ## ###### ######
## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
# ## ## ## ## ## ##
## ## ## ## ## ## ## ## ##
## ## ## ####### ###### ######");
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2014-04-11 17:02 里鞥南非
public class Test {
int x, y;
Test(int x, int y) {
this.x = x;
this.y = y;
}
public static void main(String[] args) {
Test pt1, pt2;
pt1 = new Test(3, 3);
pt2 = new Test(4, 4);
System.out.print(pt1.x + pt2.x);
}
}
回復 更多評論
# re: java在線編譯器-youjavait.com 2014-05-28 10:26 asdf
public class Test {
public static void main(String[] args){
System.out.println("abcdefg");
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2014-06-15 10:20 123灰色
Package
public class Name{
/*自己的介紹*/
public static void main(String[]args){
System.out.print("你好,我是青鳥學員\n";);
System.out.print("姓名:愛編程");
System.out.print("年齡:20歲");
System.out.print("愛好:打籃球");
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2014-06-26 02:21 1123
class Course //定義課程類
{
private int code; //設置課程代碼屬性
private String name; //設置課程名稱屬性
private int time; //設置學時屬性
private int credit; //設置學分屬性
private String classification; //設置課程類別屬性
int getCode() //獲取課程代碼
{
return code;
}
void setCode(int code) //設置課程代碼
{
this.code=code;
}
String getName() //獲取課程名稱
{
return name;
}
void setName(String name) //設置課程名稱
{
this.name=name;
}
int getTime() //獲取學時
{
return time;
}
void setTime(int time) //設置學時
{
this.time=time;
}
int getCredit() //獲取學分
{
return credit;
}
void setCredit(int credit) //設置學分
{
this.credit=credit;
}
String getClassification() //獲取課程類別
{
return classification;
}
void setClassification(String classification) //設置課程類別
{
this.classification=classification;
}
public static void main(String [] args) //主函數測試
{
Course course1=new Course(); //課程1測試
course1.setCode(1101);
course1.setName("毛概");
course1.setTime(70);
course1.setCredit(6);
course1.setClassification("社會主義");
System.out.println("課程代碼:"+course1.getCode()); //課程1打印輸出
System.out.println("課程名稱:"+course1.getName());
System.out.println("課程類別:"+course1.getClassification());
System.out.println("學時:"+course1.getTime());
System.out.println("學分:"+course1.getCredit());
System.out.println("\n");
Course course2=new Course(); //課程2測試
course2.setCode(0420);
course2.setName("思修");
course2.setTime(60);
course2.setCredit(4);
course2.setClassification("社會主義");
System.out.println("課程代碼:"+course2.getCode()); //課程2打印輸出
System.out.println("課程名稱:"+course2.getName());
System.out.println("課程類別:"+course2.getClassification());
System.out.println("學時:"+course2.getTime());
System.out.println("學分:"+course2.getCredit());
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2014-07-09 09:51 小俊
小明左,右手中分別拿著兩張牌:黑桃10和紅桃8.現在交換手中的牌,用程序模擬這一個過程;兩個整數分別保存在兩個變量中,講著兩個變量的值互換,并輸出互換后的結果。 回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2014-07-12 22:38 葉子
定義一個類Students,繼承自類Person,新增成員變量StdNo(學號),重寫成員方法ShowName,顯示當前學生的“學號+姓名”。 回復 更多評論
# re: java在線編譯器-youjavait.com [未登錄] 2014-08-21 14:17 lsy
public class A
{
public static void main(String args[])
{
String s1="java";
String s2="JavA";
System.out.println(s1.compareTo(s2));
System.out.println(s1.compareToIgnoreCase(s2));
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2014-09-27 15:19 wpyan
public class TestOnline {
public static void main(String[] args){
System.out.println("TestOnline ");
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2014-09-28 19:34 因云
public class Hello
{
public static void main(String []args)
{
System.out.printIn("Hello world");
}
}
回復 更多評論
# re: java在線編譯器-youjavait.com 2014-10-07 08:58 許繼明
import jsva.util.Scanner;
import java.util.*;
public class ProductCodes {
public static void main(String[] args)
{
String code;
char zone;
int district,valid=0,banned=0;
Scanner scan=new Scanner (System.in);
System.out.print("Enter product code (XXX to quit):");
code=scan.nextLine();
while(!(code.equals("XXX")))
{
try
{
zone=code.charAt(9);
district=Integer.parseInt(code.substring(3,7));
valid++;
if(zone=='R'&&district>2000)
banned++;
}
catch(StringIndexOutOfBoundsException exception)
{
System.out.println("Improper code length: "+code);
}
catch(NumberFormatException exception)
{
System.out.println("District is not numeric:"+code);
}
System.out.print("Enter product code (XXX to quit):");
code=scan.nextLine();
}
System.out.println("# of valid codes entered:"+valid);
System.out.println("# of banned codes entered:"+banned);
}
}
回復 更多評論
# re: java在線編譯器-youjavait.com 2014-12-01 23:53 sadsad
public class Main{
public static void main(String[] args){
int A=3;
int B=2;
System.out.println("3 + 2 = "+(A+B));
System.out.println("3 - 2 = "+(A-B));
System.out.println("3 * 2 = "+(A*B));
System.out.println("3 / 2 = "+(A/B));
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2014-12-04 00:13 1413
public class People {
private int number;
private String name;
private String sex;
private int age;
public People(){}
public People(int number,String name,String sex,int age){
this.name=name;
this.age=age;
this.number=number;
this.sex=sex;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public static void main(String []ad){
People pp= new People(001,"張三","男",23);
System.out.println("編號:"+pp.getNumber());
System.out.println("名字:"+pp.getName());
System.out.println("年齡:"+pp.getAge());
System.out.println("性別:"+pp.getSex());
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2014-12-31 18:37 - -
class Main
{
public static void main (String[] args)
{
Fuck f = new Fuck();
Thread t = new Thread(f);
t.start();
}
}
class Fuck implements Runnable
{
public void run(){
while(true){
System.out.println("fuck");
}
}
} 回復 更多評論
# re: java在線編譯器-youjavait.com 2015-01-01 00:40 sg
import java.io.BufferedOutputStream;import java.io.File;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.IOException;import java.io.PrintWriter;import java.util.Scanner;public class AddList { private String filePath = ""; private String bakPath = ""; private String content = ""; Scanner sc = new Scanner(System.in); public String readFile(){ content = ""; if (isNull(filePath)) { System.out.println("文件存儲路徑:"); filePath = sc.nextLine(); } File file = new File(filePath); FileReader fr = null; try { if (file.exists()) { fr = new FileReader(file); char[] chars = new char[1024]; int n = 0; while((n = fr.read(chars)) != -1){ String string = new String(chars, 0, n); content = content + string; } } else { System.out.println("文件不存在"); } } catch (Exception e) { e.printStackTrace(); } finally { if (fr != null) { try { fr.close(); } catch (IOException e) { e.printStackTrace(); } } } return content; } public void writeFile(String path){ File file = new File(path); FileOutputStream fos = null; mkDirs(path); try { fos = new FileOutputStream(file); BufferedOutputStream bos = new BufferedOutputStream(fos); PrintWriter pw = new PrintWriter(bos, true); pw.print(content); pw.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } public void writeFile(){ if (isNull(filePath)) { System.out.println("文件存儲路徑:"); filePath = sc.nextLine(); } File file = new File(filePath); FileOutputStream fos = null; mkDirs(filePath); try { fos = new FileOutputStream(file); BufferedOutputStream bos = new BufferedOutputStream(fos); PrintWriter pw = new PrintWriter(bos, true); pw.print(content); pw.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } public void mkDirs(String filepath){ if (filepath.indexOf("\\") != -1) { filepath = filepath.replaceAll("\\", "/"); } int n = filepath.indexOf("//"); String path = filepath.substring(0, n) + "//"; filepath = filepath.substring(filepath.indexOf("//") + 1, filepath.length()); String[] files = filepath.split("/"); for (int i = 0; i < files.length - 1; i++) { path = path + files[i]; File file = new File(path); if (!file.exists()) { file.mkdir(); } } } public void addImfor(){ System.out.println("--------增加記錄---------"); String name = ""; String tel = ""; String email = ""; content = readFile(); while(true){ System.out.println("姓名:"); name = sc.next(); System.out.println("電話:"); tel = sc.next(); System.out.println("Email:"); email = sc.next(); content = content + name + "<>" + tel + "<>" + email +"<==>"; System.out.println("0、Exit 1、繼續"); int i = sc.nextInt(); if (i == 0) { break; } } writeFile(); } public void deleteImfor(){ System.out.println("---------刪除記錄---------"); String name = ""; String[] imfors = null; content = readFile(); while(true){ System.out.println("你要刪除的姓名是:"); name = sc.next(); if (content.indexOf(name) != -1) { imfors = content.split("<==>"); for (int i = 0; i < imfors.length; i++) { if (imfors[i].indexOf(name) != -1) { imfors[i] = ""; } } 回復 更多評論
只有注冊用戶登錄后才能發表評論。 | ||
![]() |
||
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||