Loops In Java!!
| Java Discuss, Loops In Java!! at Programmers Lounge forum; The code used for this tutorial can be applied not just for Java but for other programming languages.
Loops are ... |
| Notices | Welcome to the Gamerz Needs forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |  | | 
07-22-2006, 02:39 AM
|  | Armenia | | | Last Online: Today 01:41 PM Join Date: Mar 2006 Location: Boss World :D
Posts: 2,671
Thanks: 225
Thanked 540 Times in 348 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 14 Points: 43,665.51 Bank: 499.61 Total Points: 44,165.12 | | Loops In Java!! The code used for this tutorial can be applied not just for Java but for other programming languages.
Loops are basically things that run many times. So if you want to do a function five times, instead of having the same code five times over and over, you can use a loop and it will be more efficient. It will also be easier to change a part because you will only need to change it once.
There are two types of loops that this tutorial will cover: while and for loops.
While
Example:
int i = 0;
while(i<20)
{
//some functions
i=i+1; // or i++;
}
Here is the model:
while(expression)
{
//code here
}
This will execute the code 20 times. Notice the first number i starts with is zero and not 1. If it were 1, then it would execute the function 19 times. It evaluates the expression in the parentheses before it executes the code, and it will keep executing the code until the expression is false. You can use any expression in the parentheses, and you are not limited to numbers.
For
Example
for(int i=0;i<20;i++)
{
//some functions
}
Model
for(initialize local variable;expression;function)
{
//code here
}
initialize local variable-You can initialize a local variable to serve like a counter.
expression- will continue to run the loop code until this expression is false
function- will execute this line of code after the for loop code is executed. You don't always have to put something here.
A for loop is really suited as a counter loop. It evaluates the expression, then executes the loop code.
Credits go to >Giraffe
__________________ | | The Following User Says Thank You to M0NK3Y For This Useful Post: | | 
08-20-2006, 05:57 PM
| | Stone Axe | | | Last Online: 09-10-2008 12:42 AM Join Date: Dec 2005 Age: 20
Posts: 37
Thanks: 2
Thanked 3 Times in 3 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 0 Points: 1,407.15 Bank: 956.90 Total Points: 2,364.05 | | |
... basic loops. Can be veiwed just about everywhere. Now let me give you a challenge.
In java,produce a source code which makes the computer BEEP, regardless of weather you have a speaker or not, when you run it. then apply a for loop that will loop till you close the application.
Have fun.
| 
08-23-2006, 09:37 AM
|  | Armenia | | | Last Online: Today 01:41 PM Join Date: Mar 2006 Location: Boss World :D
Posts: 2,671
Thanks: 225
Thanked 540 Times in 348 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 14 Points: 43,665.51 Bank: 499.61 Total Points: 44,165.12 | | |
LOL! thats hard!
__________________ | 
08-23-2006, 05:14 PM
| | Stone Axe | | | Last Online: 09-10-2008 12:42 AM Join Date: Dec 2005 Age: 20
Posts: 37
Thanks: 2
Thanked 3 Times in 3 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 0 Points: 1,407.15 Bank: 956.90 Total Points: 2,364.05 | |
No, not hard at all, jus requires thinking.
Let me point you in the right direction: Ascii Table - ASCII character codes html octal hex decimal charts
Its to do with ascii codes, below 10. I already hinted you too much, if you have not yet figured it out, post here (but only after you have truley taken the time to attempt it). I will give you the source code.
It bugs the hell out of my teachers :P
| 
09-23-2006, 02:31 AM
|  | The God Of Pervert | | | Last Online: 11-19-2008 03:42 PM Join Date: Jun 2006 Age: 24
Posts: 77
Thanks: 16
Thanked 13 Times in 6 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 5 Points: 521.85 Bank: 0.00 Total Points: 521.85 | | |
Thanks you so much ^^ i love XD
| 
10-23-2006, 01:52 PM
|  | Registered Users + | | | Last Online: 11-09-2008 11:51 PM Join Date: Aug 2006
Posts: 481
Thanks: 24
Thanked 42 Times in 35 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 6 Points: 1,402.19 Bank: 0.00 Total Points: 1,402.19 | | |
Is there a way to hack Rakion using java code? And if there is, is there an example to build on?
__________________ | 
10-24-2006, 01:51 AM
|  | Armenia | | | Last Online: Today 01:41 PM Join Date: Mar 2006 Location: Boss World :D
Posts: 2,671
Thanks: 225
Thanked 540 Times in 348 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 14 Points: 43,665.51 Bank: 499.61 Total Points: 44,165.12 | | |
I Think there is.... ask a hacker?
__________________ | 
02-17-2007, 08:37 PM
|  | Registered Users + | | | Last Online: 10-11-2008 07:23 PM Join Date: Oct 2005 Location: Staunton Island Age: 17
Posts: 1,244
Thanks: 43
Thanked 331 Times in 177 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 11 Points: 103,728.21 Bank: 0.03 Total Points: 103,728.24 | | Quote:
Originally Posted by Faulrn ... basic loops. Can be veiwed just about everywhere. Now let me give you a challenge.
In java,produce a source code which makes the computer BEEP, regardless of weather you have a speaker or not, when you run it. then apply a for loop that will loop till you close the application.
Have fun. | Done, took 5 minutes. Any other challenges :P.
Oh and java for hacking? Try and make a memory editor in a java compiler -_-.
__________________ | 
05-05-2007, 07:56 AM
|  | Armenia | | | Last Online: Today 01:41 PM Join Date: Mar 2006 Location: Boss World :D
Posts: 2,671
Thanks: 225
Thanked 540 Times in 348 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 14 Points: 43,665.51 Bank: 499.61 Total Points: 44,165.12 | | |
Lol.. more challenges? i did the beep thing
__________________ | 
08-27-2007, 10:08 PM
| | Stone Axe | | | Last Online: Yesterday 10:14 AM Join Date: Oct 2006 Location: Jerusalem the holy city
Posts: 42
Thanks: 9
Thanked 2 Times in 2 Posts
Nominated 0 Times in 0 Posts TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 0 Points: 1,516.02 Bank: 684.64 Total Points: 2,200.66 | | |
ok you want a challenge
i made a paint program using java language only
the specifications:
must be able to have colors,shapes,eraser,spray,fill,new page
must be able to save and load images
must be able to paint some text
must be able to specify the size of the shapes
Extras:
anything you can come up with (eg:layers and layers manipulation)
i did this in one week by myself so in one week i will post the source code unless requested to not post it
|  | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | |