Author |
Message |
Bartz Klauser BAMFing ARCHER Werewolf
Joined: 27 Sep 2007 Posts: 7637
HP: 100 MP: 5 Lives: 4
|
Posted: Mon Nov 17, 2008 6:50 pm
|
|
|
Alright, so I'm taking AP Computer Science, and we have a new lab to do, and it deals with for loops and strings, all that good stuff. So my for loops just don't work, and could anyone tell me why? I'll post my code from one program and the output from the same one.
Code: | import java.util.Scanner; public class PyramidString { public static void main (String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter the string"); String line = keyboard.nextLine(); //This statement is false. As long as it is, the for loop WILL NOT execute.// for(int i = line.length(); [b]i<=0[/b]; i--) { String lin = line.substring(0,i); System.out.println(lin); } } } |
Output:
Code: | Enter the string leet haxxorz
Process completed. |
Edit:
Theoretical Output:
Code: | Enter the string leet haxxorz
leet haxxorz leet haxxor leet haxxo leet haxx leet hax leet ha leet h leet leet lee le l
| [color=red]*strokes metaphorical beard*
Last edited by BAMFing ARCHER on Tue Nov 18, 2008 2:46 pm; edited 4 times in total |
|
Back to top |
|
|
ChaosStar Super Scourge Vampire
Joined: 15 Oct 2007 Posts: 1156
HP: 100 MP: 9 Lives: 0
|
Posted: Mon Nov 17, 2008 8:01 pm
|
|
|
Why asking us? |
|
Back to top |
|
|
The Double Duece! Strong Bad
Joined: 10 Nov 2007 Posts: 11564
HP: 99 MP: 4 Lives: 1
|
Posted: Mon Nov 17, 2008 8:12 pm
|
|
|
This made me lol. xD |
|
Back to top |
|
|
ChaosStar Super Scourge Vampire
Joined: 15 Oct 2007 Posts: 1156
HP: 100 MP: 9 Lives: 0
|
Posted: Mon Nov 17, 2008 8:18 pm
|
|
|
Exactly, I got a strike some minutes ago, and I paid the fee because I already have two strikes in the court, Francis will be on my spikes soon. I ask again: Why asking us? If this is abouthacking, your job or job, why do you think we know better?! You're lucky you even have three resoponses in this topic. |
|
Back to top |
|
|
Bartz Klauser BAMFing ARCHER Werewolf
Joined: 27 Sep 2007 Posts: 7637
HP: 100 MP: 5 Lives: 4
|
Posted: Mon Nov 17, 2008 8:44 pm
|
|
|
This is very serious. It's not for hacking. Does it look like such a simplistic program can do that? I just need to know why the for loop doesn't execute.
Edit: If you don't know anything, then get out of this post. Those three posts are the equivalents of saying "FREEPOST"*strokes metaphorical beard* |
|
Back to top |
|
|
ChaosStar Super Scourge Vampire
Joined: 15 Oct 2007 Posts: 1156
HP: 100 MP: 9 Lives: 0
|
Posted: Tue Nov 18, 2008 10:14 am
|
|
|
Well, make sure you have the latest Java update. That might help. |
|
Back to top |
|
|
Bartz Klauser BAMFing ARCHER Werewolf
Joined: 27 Sep 2007 Posts: 7637
HP: 100 MP: 5 Lives: 4
|
Posted: Tue Nov 18, 2008 2:43 pm
|
|
|
I do. And I just figured out the problem. Mods, lock this. And I'll also post the reason why at the top. |
|
Back to top |
|
|
|