评论
# 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
学习java 回复 更多评论
# 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
int a; 回复 更多评论
# 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] = ""; } } 回复 更多评论