SHARE
TWEET

Untitled

a guest Nov 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class BooleanNico {
  2.  
  3.     public static final boolean checkNum(int[] nums) {
  4.  
  5.         nums[0] = 23;
  6.         nums[1] = 22;
  7.         nums[2] = 22;
  8.         nums[3] = 22;
  9.         nums[4] = 23;
  10.         ///Dem Array Inhalt verleihen///
  11.        
  12.        
  13.         boolean booldeslebens = true; //2. Boolean für den for loop
  14.        
  15.         for (int i = 0; i < nums.length; i++) {
  16.             int zaehler = 4;
  17.  
  18.             if (nums[i] != 23 && nums[zaehler] != 23) {
  19.                 return !booldeslebens; //Wenn nums nicht gleich 23 an der ersten stelle && an der letzten stelle == false
  20.             }
  21.             i++;
  22.         }
  23.         return booldeslebens; //Wenn nums 1. und letzte Stelle gleich sind == true
  24.     }
  25.  
  26.     public static void main(String[] args) {
  27.         int nums[] = { 23, 22, 22, 22, 23 }; //Das Array (Feld) bekommen.
  28.  
  29.         if (checkNum(nums) == true) {
  30.             System.out.println("Der Hase sagt True");
  31.         } else {
  32.             System.out.println("Der Igel sagt aber Nein");
  33.         }
  34.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top