digibutter.nerr Forum Index
Hey [you]! If you haven't noticed, this is now the old digibutter forums. Go over to the new site!
digibutter.nerr
It's Hi-Technicaaal!

Help with Java (Don't bother if you don't know. Seriously.)
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    digibutter.nerr Forum Index -> Hi-Technical Support
Author Message
Bartz Klauser
BAMFing ARCHER
Werewolf


Joined: 27 Sep 2007
Posts: 7637

HP: 100 MP: 5 Lives: 4



PostPosted: Mon Nov 17, 2008 6:50 pm   Reply with quote

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
The Town of Lix    
ChaosStar
Super Scourge
Vampire


Joined: 15 Oct 2007
Posts: 1156
HP: 100 MP: 9 Lives: 0



PostPosted: Mon Nov 17, 2008 8:01 pm   Reply with quote

Why asking us? Confused
Back to top
   
The Double Duece!
Strong Bad



Joined: 10 Nov 2007
Posts: 11564

HP: 99 MP: 4 Lives: 1



PostPosted: Mon Nov 17, 2008 8:12 pm   Reply with quote

This made me lol. xD
Back to top
Toad House    
ChaosStar
Super Scourge
Vampire


Joined: 15 Oct 2007
Posts: 1156
HP: 100 MP: 9 Lives: 0



PostPosted: Mon Nov 17, 2008 8:18 pm   Reply with quote

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



PostPosted: Mon Nov 17, 2008 8:44 pm   Reply with quote

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
The Town of Lix    
ChaosStar
Super Scourge
Vampire


Joined: 15 Oct 2007
Posts: 1156
HP: 100 MP: 9 Lives: 0



PostPosted: Tue Nov 18, 2008 10:14 am   Reply with quote

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



PostPosted: Tue Nov 18, 2008 2:43 pm   Reply with quote

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
The Town of Lix    
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    digibutter.nerr Forum Index -> Hi-Technical Support
All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group