public static void main(String[] args){
String firstString="This is";
#String secondString="This is";
if(firstString==null & secondString==null){
System.out.println("①firstString 與 secondString 相等");
}else if(firstString!=null & firstString.equals(secondString)){
System.out.println("①firstString 與 secondString 相等");
}else{
System.out.println("①firstString 與 secondString 不相等");
}
String str = firstString "his father";
System.out.println("②" str);
System.out.println("③" str.replaceAll("i", "z"));
}
println("
BufferedReader distream = new BufferedReader(new InputStreamReader(
System.IOException;)!!
try {
System.out,ppackage com.ascent.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (read.equals("程式結束!;/判斷輸入的是否為q
break.println(result);
}
}
應該很詳細了;
}
System.io.InputStreamReader;
/:"!"
#while (true) {
String read = null;i")) {/請輸入一個字元;= n; j
result = result * 3;
}
System.out.println(result);
}
if (read.equals(".BufferedReader;
import java.io.println("/建立一個輸入流,接受從從控制台輸入的一個字符,q三個字符進行了相應的處理; j ) {
result = result * j;判斷輸入的是否為p
for (int j = 1;
double result = 1;)) {//);/判斷輸入的是否為i
for (int j = 1; j <.out;
}
System;q"))/!!
public class TestLession {
public static void main(String[] args) {
int n= 10.out.in));/.test;
#import java.io;
import java;
read = distream;/本程式只對i!!;
}
if (read.equals("p"
import java.util.*;
public class Tester{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
System.out.print("輸入一組資料:");
String line = sc.nextLine().trim();
if(!line.matches("^\\d (\\s \\d )*$")){
System.out.print("輸入錯誤,");
continue;
}
String[] arr = line.split("\\s ");
System.out.println(Arrays.toString(arr));
sc.close();
break;
}
}
}
public class Search {
public static final int[][] array ={
{8,2,3,4,5},
{7,6,5,8,8},
{6,4,5,7,10}
};
public static void main(String[] args) {
for(int i=0;i
int minCol = getrowMin(i);
if(iscolMin(minCol,i)){
System.out.println("array[" i "][" minCol "]");
}
}
}
public static int getrowMin(int rowNo){
int min=array[rowNo][0];
int col=0;
for(int i=1;i
if(array[rowNo][i] min=array[rowNo][i]; col=i; } } return col; } public static boolean iscolMin(int colNo,int rowNo){ for(int i=0;i
if(array[i][colNo]
} return true; } }
以上是寫一個JAVA簡單的程式!的詳細內容。更多資訊請關注PHP中文網其他相關文章!