A. java中判斷條件if的簡單寫法
寫個方法 如:
static void fillParam(Criterion[], String param){
if(param != null){
//添加到Criterion[] 數組中
}
}
B. java 開啟多線程裡面如何加條件判斷執行其他邏輯
package test; import java.util.concurrent.CountDownLatch;import java.util.concurrent.Executor;import java.util.concurrent.Executors; public class WatchThread { public void testThread() throws InterruptedException {int threadNum = 10;// 初始化countDownCountDownLatch threadSignal = new CountDownLatch(threadNum);// 創建固定長度的線程池Executor executor = Executors.newFixedThreadPool(threadNum);for (int i = 0; i < threadNum; i++) { // 開threadNum個線程Runnable task = new TestThread(threadSignal);// 執行executor.execute(task);}threadSignal.await(); // 等待所有子線程執行完// do workSystem.out.println(Thread.currentThread().getName() + "");} /*** 測試函數*/public static void main(String[] args) throws InterruptedException {WatchThread test = new WatchThread();test.testThread();} private class TestThread implements Runnable {private CountDownLatch threadsSignal; public TestThread(CountDownLatch threadsSignal) {this.threadsSignal = threadsSignal;} public void run() {System.out.println(Thread.currentThread().getName() + "開始...");// do shomethingSystem.out.println("開始了線程::::" + threadsSignal.getCount());// 線程結束時計數器減1threadsSignal.countDown();System.out.println(Thread.currentThread().getName() + "結束. 還有"+ threadsSignal.getCount() + " 個線程");}} }
C. java怎麼用條件判斷做員工實發工資
判斷工資可以使用等等於和if進行判斷。
員工工資組成一般由基本工資,績效,出差補貼,通話補貼,房屋補貼以及餐補組成,Java中設置基本邏輯符號將以上工資和補貼進行計算,最後使用if語句或者等等於符號進行比較判斷,員工人數過多時並且知道員工人數的情況下增加for循壞,減少工作量。