DISQUS

Tech-Recipes: Java for loop iteration syntax | Java programming | Tech-Recipes

  • tin2 · 1 year ago
    better luck next time
  • janak_kumar · 10 months ago
    i want many type of for loop code
  • seema · 7 months ago
    good
  • Peter · 5 months ago
    concerning i < array.length: if you really want to run through each array item, you need to initialize i with 0:
    for (int i = 0; i < array.length; i++) {
    System.out.println(array[i]);
    }
  • Gobitha · 5 months ago
    please give appropriate generic syntax form to this for loop
    "for(int i:arr){System.out.println(i);}"
  • donatjava · 4 months ago
    simpl program for loop
  • fiaeriza · 3 months ago
    how to do the program and output like this:
    #######
    ######
    #####
    ######
    #####
    ###
    ##
    #
  • usernamer · 2 months ago
    please fix it for me!

    /**
    * @(#)hehe.java
    *
    *
    * @author
    * @version 1.00 2009/10/7
    */

    import java.io.*;
    public class hehe{

    public static void main(String args[]) throws IOException {

    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    int user;
    int pass;
    int i=1;
    String yesno;
    char yorn;



    while(i<=3){
    System.out.print("Enter Username:");
    user=Integer.parseInt(input.readLine());
    System.out.print("Enter Password:");
    pass=Integer.parseInt(input.readLine());
    for(int j=0;j<=5;j++){
    System.out.println();
    }
    System.out.println();
    if((user==2009)&&(pass==2010)){
    System.out.println("ACCESS GRANTED!");
    for(int j=0;j<=5;j++){
    System.out.println();
    }
    System.out.println();


    }else
    {
    System.out.println("=ACCESS DENIED=");
    System.out.println("Please Try Again");
    for(int j=0;j<=5;j++){
    System.out.println();
    }
    }
    i++;






    String choice;

    System.out.println("Choices:");
    System.out.println("A.PURCHASING ITEMS");
    System.out.println("B.EXIT");
    System.out.print("Enter Your Choice: ");
    choice=input.readLine();
    if (choice.equals("A"))
    {






    }else if(choice.equals("B"))

    {
    System.out.println("Do you really want to exit?");
    System.out.println("Yes(Y)No(N)");
    yesno=input.readLine();
    }




    }

    }
    }
  • diamishra · 4 weeks ago
    the description is not very good