简单的小程序实现ATM机操作 代码如下: package Day06; import java.util.Scanner; public class TestAccount { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Account[] accountArray = new Account[3]; for (int i = 0; i < accountArray.length; i…
public class helloworld { public static void main(string[] args) { system.out.println("hello world!"); } } 首先编译,进入E盘,输入“e:”然后enter 接着输入 Javac helloworld.java 就是这个5行的小程序,出现了3个错误 1:错误:类helloworld是公共的,应在名为 helloworld.java 的文件中声明 public class hellow…
1. 利用循环打印如下图形 ***** **** *** ** * public class Main { public static void main(String[] args) { // TODO Auto-generated method stub int i = 5; while (i >= 0) { for (int j = i; j > 0; j--) System.out.print("*"); System.out.println(); i--; } }…
判断闰年. package com.test; import java.util.Scanner; import org.junit.Test; public class TestRunNian { @Test public void test1() { Scanner scanner = new Scanner(System.in); while (true) { int year = scanner.nextInt(); if (year == -1) { System.out.printl…
package com.test; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import org.junit.Test; public class TestSwitch { @Test public void test() { List<Integer> list = new ArrayList<Integer>(); for (int i = 10 * 1000…
package com.test; import java.util.Scanner; import org.junit.Test; import com.sun.xml.internal.ws.api.pipe.NextAction; public class TestSwitch { @Test public void test() { Scanner sc = new Scanner(System.in); try { while (true) { int n = sc.nextInt()…
使用二分法在一个数组中查找一个数: package com.test; public class BinaryFind { private final static int size = 500000; public static void main(String[] args) { int[] a = new int[size]; for (int i = 0; i < size; i++) { a[i] = i + 1; } find(a, -500001155); } private st…