AuthorMessage
jackel
n00b
Posts: 41

Today i learned while loop in java 
 < --- This is what i got tought ---- >
Code:

//==========================//
//Name: jackel                              //
//Tutor: A.Wizard                       //
//Whileloop                               //
//Date: OCT12th                     //
//=====================//
    
    public class loopy
{   public static void main (String [] args)
{   
   int thisnumber;
   thisnumber = 2;
   while(thisnumber <= 100)
{   thisnumber = thisnumber *2;
    System.out.println ("the value of thisnumber is " + thisnumber);
{   
    System.out.println ("coding for TEAMELITE TR00PS");
}   
}
}
 
}

EDIT: you are still keep forgetting the code brackets -/Meka
does anyone know any other ways of doing while loop ior any other handy trix tr00ps TIA
R€€SP€CT
jackel
jackel
n00b
Posts: 41

this is one from tutor br3 i ran the while loop & all was well my code ran fine i cant see the brackets im missing meka br3 but if you look this from college maybe it teh way i get tought is different or is it mistake im making --- > code from college kk
Code:

public class While_X {
   public static void main (String [] args) {
      int x;
      x = 2;
      while (x <= 50) {
         x = x * 2;
         System.out.println ("The value of x is " + x);
      }
   }
}

AIGHT br3 i like to keep my brackets on the wall  unlike this copy meka , is this code fine or wrong with brackets < --- this is what i am being tought if its wrong i wanna be first to tell them thx man ;)  like the last 3 closing brackets i try tokeep all my brackets on the wall i think it looks tidyer but if it fooks me code up il be changing that the more help the better TIA ;-)   so all brackets on wall a bad idea. i was just hit enter b4 my braces\brackets to make look neat & tidy  BUT IF THE ABOVE CODE LOOKS BETTER PLZ LET ME KNOW thx again :]
R€€SP€CT
jackel
Nina
Ametuar
Posts: 134

it isn't about looking better,it reads better! Nina
rameshkumar
Clone
Posts: 1

Hi Thi mr Ramesh From India Right Know while Loop tell How its better to Use  8)
Let See
Code:
public class Login
{
 int i;
public class static void main(String arg[])
{
while {i=o; <lenght<i; i++}
}
public class Login Extend BaseClass();
{
super();
}
sysem.out.prinln(lenght(i) 'i+' )
}

But We have Extends to while In Base class pls tell how it work
if it possable print out i++
 
Meka][Meka
Unstopable
Posts: 700

uhm can you rephrase what you posted... ?
Nina
Ametuar
Posts: 134

Code:
public class Login {
   
   public static void main(String[] args) {
      
      int i = 0;
      // for loop
      for (i = 0; i < 50; i++) {
         System.out.println(i++);
      }
      
      // while loop
      while (i < 50) {
         System.out.println(i++);
         i++;
      }
      
   }
   
}

please be more specific about the BaseClass(). what do you want to use it for?
greets, nina
Nina
Ametuar
Posts: 134

unless it's this you wanted.
Code:

Login.java
public class Login {
   
   public Login(int i) {
      SomeClass s = new SomeClass(i);         
   }
   
   public static void main(String[] args) {
      int i = 0;
      int length = 50;
      while (i < length) {
         Login l = new Login(i++);
         i++;
      }
   }
      
}
SomeClass.java
public class SomeClass {
   public SomeClass(int i) {
      System.out.println(i++);
   }
   
}