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 ...


Go Back   Gamerz Needs - For All Your Gaming Needs! > Technology Zone > Programmers Lounge > Java
Forgot Password? | Sign Up!

Notices

Advertisement
   

Closed Thread
 
Bookmark this Thread Tools Display Modes
  #1  
Old 07-22-2006, 02:39 AM
M0NK3Y's Avatar
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
M0NK3Y will become famous soon enough
Points: 43,665.51
Bank: 499.61
Total Points: 44,165.12
Banana *yey* i <3 banana milkshake - Demonite cuz you back again lol - GameLordquest wanne do it again? xD - DeathniteR AYE AYE PIRATE! DRINK YOUR BEERZ! - M0NK3Y Im a M0NK3Y Pirate so.. i need a banana! :D - M0NK3Y 
No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y 
Black - Andrex2x Burgundy - Demonite Black - Demonite Burgundy - Demonite 
Send a message via ICQ to M0NK3Y Send a message via AIM to M0NK3Y Send a message via MSN to M0NK3Y Send a message via Yahoo to M0NK3Y
Exclamation 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:
dragoon (07-23-2006)
  #2  
Old 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
Faulrn is an unknown quantity at this point
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.
  #3  
Old 08-23-2006, 09:37 AM
M0NK3Y's Avatar
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
M0NK3Y will become famous soon enough
Points: 43,665.51
Bank: 499.61
Total Points: 44,165.12
Banana *yey* i &lt;3 banana milkshake - Demonite cuz you back again lol - GameLordquest wanne do it again? xD - DeathniteR AYE AYE PIRATE! DRINK YOUR BEERZ! - M0NK3Y Im a M0NK3Y Pirate so.. i need a banana! :D - M0NK3Y 
No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y 
Black - Andrex2x Burgundy - Demonite Black - Demonite Burgundy - Demonite 
Send a message via ICQ to M0NK3Y Send a message via AIM to M0NK3Y Send a message via MSN to M0NK3Y Send a message via Yahoo to M0NK3Y
LOL! thats hard!
__________________
  #4  
Old 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
Faulrn is an unknown quantity at this point
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
  #5  
Old 09-23-2006, 02:31 AM
chivien's Avatar
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
chivien is on a distinguished road
Points: 521.85
Bank: 0.00
Total Points: 521.85
Thanks you so much ^^ i love XD
  #6  
Old 10-23-2006, 01:52 PM
amdjebb's Avatar
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
amdjebb is on a distinguished road
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?
__________________

  #7  
Old 10-24-2006, 01:51 AM
M0NK3Y's Avatar
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
M0NK3Y will become famous soon enough
Points: 43,665.51
Bank: 499.61
Total Points: 44,165.12
Banana *yey* i &lt;3 banana milkshake - Demonite cuz you back again lol - GameLordquest wanne do it again? xD - DeathniteR AYE AYE PIRATE! DRINK YOUR BEERZ! - M0NK3Y Im a M0NK3Y Pirate so.. i need a banana! :D - M0NK3Y 
No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y 
Black - Andrex2x Burgundy - Demonite Black - Demonite Burgundy - Demonite 
Send a message via ICQ to M0NK3Y Send a message via AIM to M0NK3Y Send a message via MSN to M0NK3Y Send a message via Yahoo to M0NK3Y
I Think there is.... ask a hacker?
__________________
  #8  
Old 02-17-2007, 08:37 PM
Cockney's Avatar
Registered Users +
 
Last Online: 10-11-2008 07:23 PM
Join Date: Oct 2005
Location: Staunton Island
Age: 17
Posts: 1,244
Donation Level 2 
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
Cockney is on a distinguished road
Points: 103,728.21
Bank: 0.03
Total Points: 103,728.24
Send a message via AIM to Cockney
Quote:
Originally Posted by Faulrn View Post
... 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 -_-.
__________________
  #9  
Old 05-05-2007, 07:56 AM
M0NK3Y's Avatar
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
M0NK3Y will become famous soon enough
Points: 43,665.51
Bank: 499.61
Total Points: 44,165.12
Banana *yey* i &lt;3 banana milkshake - Demonite cuz you back again lol - GameLordquest wanne do it again? xD - DeathniteR AYE AYE PIRATE! DRINK YOUR BEERZ! - M0NK3Y Im a M0NK3Y Pirate so.. i need a banana! :D - M0NK3Y 
No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y No Message - M0NK3Y 
Black - Andrex2x Burgundy - Demonite Black - Demonite Burgundy - Demonite 
Send a message via ICQ to M0NK3Y Send a message via AIM to M0NK3Y Send a message via MSN to M0NK3Y Send a message via Yahoo to M0NK3Y
Lol.. more challenges? i did the beep thing
__________________
  #10  
Old 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
garbett1 is on a distinguished road
Points: 1,516.02
Bank: 684.64
Total Points: 2,200.66
Send a message via Skype™ to garbett1
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
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Advertisement
   


Main Navigation
Home
GzN Forums
GzN Games
GzN News
Top Games
GzN Cheats
GzN Articles
GzN Reviews
GzN Downloads
User Control Panel
Advertising
RSS Feed
2Moons
Adventure Quest
AirRivals
America's Army
Anarchy Online
Archlord
Audition
Battlefield Series
Cabal Online
Call Of Duty Series
Combat Arms
Conquer Online
Counter Strike
Day of Defeat
Deicide Online
Diablo Series
Doom Series
Drift City
Enemy Territory
Eudemons Online
Final Fantasy
Flyff (Fly For Fun)
General Game Discussion
Ghost Online
Granado Espada
Grand Theft Auto Series
Guild Wars
Gunbound
Gunz Online
Habbo Hotel
Half-Life 2
Hero Online
KartRider
Knights Online
Maple Story
Medal of Honor
MU Online
Neopets
Pangya
Quake Series
Ragnarok Online
Rappelz
Rakion
Red Orchestra
Rose Online
Runescape
Scions of Fate
Silkroad Online
Sims Series
Soldier Front
Starcraft
Tales of Pirates
Tibia
The Ship
Trickster Online
TS Online
Unreal Tournament
War Rock
WolfTeam
World of Warcraft & Series
Affiliates
COD4 Hacks
BF2 Hacks


All times are GMT -8. The time now is 03:53 PM.