Skip to content

Instantly share code, notes, and snippets.

/*
application 程式架構
*/
//package區 :定義此成是屬於哪個package
// :一定在程式的一開始,一個程式只能有一個package
//import區
//import java.lang.*;
//import java.awt.*;
/*
* 第一個Java程式
*/
public class Ex02_001 {
public static void main(String args[]){
String string;
import java.io.*;
public class Ex03_101 {
public static void main(String args[]) throws IOException{
// 宣告字串變數
String ans ;
// 輸出說明
System.out.printf("請輸入成績\n");
import java.io.*;
public class Ex03_103 {
public static void main(String args[]) throws IOException {
// 宣告字串變數
String ans;
// 輸出說明
System.out.printf("請輸入成績\n");
import java.io.*;
public class Ex03_201 {
public static void main(String args[]) throws IOException {
// 宣告整數變數
int i;
// 宣告double變數
double sum = 0;
import java.io.*;
public class Ex03_202 {
public static void main(String args[]) throws IOException {
// 宣告整數變數
int i = 0; // 計算用
int x; // 終值
int sum = 0; // 總值
import java.io.*;
public class Ex03_203 {
public static void main(String args[]) throws IOException {
// 宣告整數變數
int x; // 存放數字
// while重複結構 while(判斷式)
do {
public class Ex03_204 {
public static void main(String args[]) {
// 宣告整數變數
int i;
// break指令效果
System.out.print("break指令效果\n");
// 令i從1到100
public class Ex04_101 {
public static void main(String args[]) {
// 原始資料型態陣列==========================================================
// 宣告陣列方式1
int[] ary1;
ary1 = new int[10];
// 宣告陣列方式2
import java.io.*;
public class Ex04_202 {
public static void main(String args[]) throws IOException {
// 宣告整數變數
int i, j, x;
// 宣告存放數字的陣列
int[] ary = new int[10];