Advertise Here

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Steven

Pages: [1] 2 3 4 ... 9
1
Java / Re: Java Loop Explained
« on: November 25, 2009, 05:41:18 pm »
In order to make this java loop topic more "complete" let's add the while, do while, and for each loop, break, and continue examples here as well =P

WHILE LOOP

Code: (java) [Select]
int i = 1;
while(i <= 5){
     System.out.println(i);
     i++;
}

Just like in the example above, this piece of code will print every number from 1 to 5. The thing about the While loop is that it is used mainly for boolean expressions (such as the above where the code will only execute as long as i is less than or equal to 5) but can also be used as follows:

Code: (java) [Select]
boolean a = true;
int i = 1;
while(a){
     if(i >= 5)
          a = false;
     System.out.println(i);
}

Now in this example, we check whether or not I is greater than or equal to 5. When it is equal to 5 we set a to false so that the loop will terminate on the next execution. Now let's take a look at do while.

DO WHILE

The point of a do while is to execute a while loop AT LEAST ONCE regardless of condition, because conditions are checked after the loops execution. This is generally useful when you receive user input that will determine the execution of a loop, but regardless of their input you would want the loop to run at least once. Here's an example of the do while loop, using the exact same example as our previous while loop.

Code: (java) [Select]
boolean a;
int i = 1;
do{
     if(i >= 5)
          a = false;
     System.out.println(i);
}while(a)

Notice how the while part is the last bit of the loop, this is why a would not have to be initialized until it becomes false.

FOR EACH


FOR EACH loops are used for iterating within arrays, it really makes it a lot easier, and more efficient, than using a regular for loop. Here is an example with an array of length 4, and you want to print each individual part of the array. I will show how it would look in your regular for loop, then in a foreach loop.

for:
Code: (java) [Select]
String array[] = {"Hi", "There", "My", "Son"}
for(int i = 0; i<array.length; i++)
     System.out.print(array[i]);

foreach:
Code: (java) [Select]
String array[] = {"Hi", "There", "My", "Son"}
foreach(String x : array)
     System.out.print(x);

you tell me which looks better ;)

BREAK AND CONTINUE

These two commands are quite crucial to loops, which is why I added them in here.

the "break" command breaks out of a loop, while the continue command skips the rest of the loop, and begins the iteration from the next step. For example, let's say you have a loop where you need the loop to terminate if a certain condition is met. All you would do is have an if statement using the break command and you'd be set! Example:

Code: (java) [Select]
if(condition)
     break;

as for the continue command would be the same, only it would be if you find something where you want the rest of the loop to be ignored, and then re-iterate as normal from the next iteration of the loop.

Code: (java) [Select]
if(condition)
     continue;

Hopefully this guide on loops is more complete for you guys ^^

2
General Support / Re: How do i get a e-mail system...
« on: August 29, 2007, 06:59:17 pm »
i already gave u the tools to do everything, if ur parents don't let u then u should just w8 till they do  ;)

3
General Support / Re: How do i get a e-mail system...
« on: August 28, 2007, 06:00:32 pm »
my cell is metro so i never recieve the confirmation. sorry, ask som1 in ur family to do it? (other than ur mom or dad)

4
General Chat / Re: Very Important
« on: August 27, 2007, 04:22:14 pm »
u would have to buy a domain. for example you can go to http://www.domain.com/ to buy a domain there. then simply use that domain to redirect to your forum, and mask teh adress. your forum would now be theultimates.com or w\e assuming that that domain isnt taken. a domain usually does not cost less than 10 dollars for a whole year, and if it does cost more than they better have some out of this world services lol.

5
General Support / Re: How do i get a e-mail system...
« on: August 27, 2007, 03:44:52 pm »
assuming u have a house fone, call up a friend or family member and ask them to let u use their fone num, then they give u the code when they get it.

6
General Support / Re: How do i get a e-mail system...
« on: August 26, 2007, 08:33:33 am »
no...it worked for me and i have bellsouth....no w8 i mean at&t....they bought out bellsouth...w\e..o and dont use the link i gave above, use this one: https://domains.aol.com/personaldomain/app/domainMainSearch

7
General Support / Re: How do i get a e-mail system...
« on: August 22, 2007, 04:04:19 pm »
actually aol offers free email domain services. i had the link but i deleted it. so u could sign up with mye-mail@rs2server.net threw aol. im not sure if they still offer that although they should. ima look for the link gimme a sec....ok here it is: https://domains.aol.com/personaldomain/app/domainHomeSearch

8
General Support / Re: music
« on: August 17, 2007, 08:52:13 am »
np lol...but didnt kimmie already give u this piece of information?

9
General Support / Re: music
« on: August 17, 2007, 08:36:46 am »
for the music player at the bottom admin cp> manage styles> edit headers and footers place the music player code in the footers. for the shout box you can either place it in headers or footers, or you can place it in a board description

10
General Chat / Re: Redirecting URL * With Pics To Explain *
« on: August 16, 2007, 11:46:48 am »
yes ^_^

11
General Chat / Re: Redirecting URL * With Pics To Explain *
« on: August 16, 2007, 11:44:05 am »
btw the url shouldnt be www.chemicalscape.smfforfree2.com it should be http://chemicalscape.smfforfree2.com/index.php you can have the www if you want but it is not needed.

12
General Support / Re: adding a banner
« on: August 16, 2007, 09:36:50 am »
np ^_^

13
General Support / Re: adding a banner
« on: August 16, 2007, 09:20:59 am »
upload ur banner to photobucket or any similar image host with hotlinking.  then go into admin cp> current theme and put the url in that first thing where it says banner url or somthing. then click save and boom its there.

14
General Support / Re: Need a Site that will let me re-direct
« on: August 15, 2007, 02:49:07 pm »
i think this site allows you to register for a domain, and then gives you redirection for free, at least that's what they claim on their home page. if you do register with them and it doesn't work you can always transfer your domain to some other host.

15
well you are not using an smf for free forum so let me link ya to the support forums for normal smf forums

smf support

thats the general english support forum, im sure they will be happy to help you out with your problem.

Pages: [1] 2 3 4 ... 9