|
On May 28 2009 09:54 RaGe wrote:Maybe you should stop being so defensive and read the fucking solution for a change. Show nested quote +On May 28 2009 09:38 RaGe wrote: When an exception gets thrown, it immeadiately skips to the Catch, which is at the end of your program, so it terminates the program cause there's no following lines of code
Your catch block is outside of the while loop, so it doesn't continue in the while loop after it executes the catch block. Java does not magically read your mind. This wasn't supposed to work. This isn't some obscure error. This is you skipping through whatever 'How to handle exceptions' guide you read, copy pasting some stupid shit that you don't understand, and asking tl to fix your errors.
seems like he answered the question pretty obviously to me
|
.. so RaGe agrees , to argue with SFSkabam .. and you ban him before RaGe even replies?
|
o noz lets not even address any points of his new post and just ban him
|
i dunno maybe you should take the time to properly indent the code if you want people to take the time to read it. might want to give it some white space too
|
I mean jesus christ, have you read the begginning of the thread? RaGe started posting shit , pretty much unprovoked as far as i can tell
|
aers
United States1210 Posts
it should be throwing an error, catching it, and then going back to the while loop.
Your problem is this is wrong. That's not how try/catch loops work. That is exactly what RaGe pointed out in his first post.
1) try <something> 2) throw exception 3) catch exception 4) execution continues after try/catch block
|
Calgary25980 Posts
His first post was talking shit to a moderator, so yes, I ban him. His "real" first post was showing no humility and talking shit to people trying to help him.
|
On May 28 2009 11:03 mahnini wrote: i dunno maybe you should take the time to properly indent the code if you want people to take the time to read it. might want to give it some white space too can we drop this read the thread before you post here it is for you
On May 28 2009 10:02 Abydos1 wrote:Show nested quote +On May 28 2009 10:01 Malongo wrote: HOE I have a suggestion to make life easier to you: Identation: helps to find easily where your code blocks belong, I hate to see a code that ends in 3/4 brackets and I dont know where the fuck they belong.
fyi, it is indented but quote doesn't show them correctly.
|
On May 28 2009 11:04 HeavOnEarth wrote: I mean jesus christ, have you read the begginning of the thread? RaGe started posting shit , pretty much unprovoked as far as i can tell
On May 28 2009 09:38 RaGe wrote: When an exception gets thrown, it immeadiately skips to the Catch, which is at the end of your program, so it terminates the program cause there's no following lines of code
program is doing what you made it to do lol
Yeah man, that was quite posting shit, much unprovoked as far as I can tell too.
|
|
[ indent ]
makes it 10x easier to read and shows some effort at least. anyway, doesnt really matter cause people sifter through the code anyway and told him what was wrong and he spazzed out.
|
On May 28 2009 11:06 Elemenope wrote:Show nested quote +On May 28 2009 11:04 HeavOnEarth wrote: I mean jesus christ, have you read the begginning of the thread? RaGe started posting shit , pretty much unprovoked as far as i can tell Show nested quote +On May 28 2009 09:38 RaGe wrote: When an exception gets thrown, it immeadiately skips to the Catch, which is at the end of your program, so it terminates the program cause there's no following lines of code
program is doing what you made it to do lol Yeah man, that was quite posting shit, much unprovoked as far as I can tell too.
I'd assume he's talking about Rage's second post, which is a small bit on the offense, however, the way the OP handled it from there... /facepalm
|
rage's first post answered the OP perfectly, shouldve just been closed after it >.>
|
Calgary25980 Posts
Yes I agree Rage escillated it unprovoked. But it's pretty obvious that: 1) You martyr yourself in the first post (slap to moderators' face). 2) It's obviously homework. 3) You don't know what you're doing.
Had you approached with humility and addressed the above three points, we wouldn't be in this situation. Yes, Rage should have been more forgiving and not attacked you/your friend, but after being clearly proven wrong your friend degraded into just insulting everyone. That doesn't fly here.
|
On May 28 2009 11:06 Elemenope wrote:Show nested quote +On May 28 2009 11:04 HeavOnEarth wrote: I mean jesus christ, have you read the begginning of the thread? RaGe started posting shit , pretty much unprovoked as far as i can tell Show nested quote +On May 28 2009 09:38 RaGe wrote: When an exception gets thrown, it immeadiately skips to the Catch, which is at the end of your program, so it terminates the program cause there's no following lines of code
program is doing what you made it to do lol Yeah man, that was quite posting shit, much unprovoked as far as I can tell too.
wow i get more and more convinced you have no idea what you're doing and just copy pasted shit
it's not copy pasted? at this point he's insulting me as well ; not just my friend
IN response to this
On May 28 2009 09:49 HeavOnEarth wrote:Show nested quote +On May 28 2009 09:38 RaGe wrote: When an exception gets thrown, it immeadiately skips to the Catch, which is at the end of your program, so it terminates the program cause there's no following lines of code
program is doing what you made it to do lol Firstly, the throw is inside a while loop. What I'm wondering is why the crap it isn't continuing the while loop, opposed to what it does now; which is ends the program. It should not be ending the program, it should be throwing an error, catching it, and then going back to the while loop. Show nested quote +On May 28 2009 09:44 RaGe wrote: wow i get more and more convinced you have no idea what you're doing and just copy pasted shit or something
i mean, your catch block is:
catch(StringTooLongException e){ System.out.println(e.getMessage()); System.out.println("Exception caught! Ending program."); }
you even print that you're ending the program and you dont want it to end the program? Oh noes, I has a random print line that hasn't been changed from a previous version. Printing text doesn't end a program. ... (At least not this one)
Rage posts Maybe you should stop being so defensive and read the fucking solution for a change.
|
If you're only using the try/catch block to look for StringTooLongExceptions before printing the input string, you can do this without obfuscating the code by using continue.
+ Show Spoiler + import java.util.Scanner; public class UserInput{
public String done= "DONE";; public Scanner scan = new Scanner(System.in); public String scanned = "";
public UserInput(){
System.out.println("Type a string. Max 20 characters."); System.out.println("Type DONE, in all caps to end."); while(scanned.compareTo(done) != 0){ try{ scanned = scan.next(); if(scanned.length() > 20){ throw new StringTooLongException(); } System.out.println(scanned); } catch(StringTooLongException e){ System.out.println(e.getMessage()); System.out.println("Exception caught! Continuing..."); } } }
}
becomes
+ Show Spoiler + import java.util.Scanner; public class UserInput{
public String done= "DONE";; public Scanner scan = new Scanner(System.in); public String scanned = "";
public UserInput(){
System.out.println("Type a string. Max 20 characters."); System.out.println("Type DONE, in all caps to end."); while(scanned.compareTo(done) != 0){ scanned = scan.next(); if(scanned.length() > 20){ System.out.println("Input String was too long."); continue; } System.out.println(scanned); } }
}
Note that I'm not familiar with the Scanner class, but it doesn't look like it should throw exceptions based on your code. Given that, there is no reason to use a try/catch block.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html
|
Chill you're naught but a pathetic power hungry 13 year old? I like how I get BM'd first, and I'm the bad guy. Rofl. Seriously, almost the entire TL.net community is fucking trash, including the mods. Seriously, why was Kawaii so pissed about this pathetic site.
Lawl, banned: Reason: Incosiderate newb. Try harder on your next account.
There will be no more accounts (other than this one)? This site was trash the first time I used it, and it was again, even on Nam's account when I was extremely fucking GM. First some pathetic piece of shit mod closes the first thread, and then I get lawl'd by RaGe, who gains a fuckton of retards behind him? Seriously, you people need to burn at the stake.
|
On May 28 2009 11:08 Chill wrote: Yes I agree Rage escillated it unprovoked. But it's pretty obvious that: 1) You martyr yourself in the first post (slap to moderators' face). 2) It's obviously homework. 3) You don't know what you're doing.
Had you approached with humility and avoided the above three points, we wouldn't be in this situation. Yes, Rage should have been more forgiving and not attacked you/your friend, but after being clearly proven wrong your friend degrading into just insulting everyone. That doesn't fly here. 3)He didn't even have a chance to explain what he understands and RaGe shits all over him on it?
2)How is trying to understand something homework- we already posted the code, hell we fixed it as well.
|
|
Calgary25980 Posts
On May 28 2009 11:08 HeavOnEarth wrote:Show nested quote +On May 28 2009 11:06 Elemenope wrote:On May 28 2009 11:04 HeavOnEarth wrote: I mean jesus christ, have you read the begginning of the thread? RaGe started posting shit , pretty much unprovoked as far as i can tell On May 28 2009 09:38 RaGe wrote: When an exception gets thrown, it immeadiately skips to the Catch, which is at the end of your program, so it terminates the program cause there's no following lines of code
program is doing what you made it to do lol Yeah man, that was quite posting shit, much unprovoked as far as I can tell too. Show nested quote + wow i get more and more convinced you have no idea what you're doing and just copy pasted shit
it's not copy pasted? at this point he's insulting me as well ; not just my friend IN response to this Show nested quote +On May 28 2009 09:49 HeavOnEarth wrote:On May 28 2009 09:38 RaGe wrote: When an exception gets thrown, it immeadiately skips to the Catch, which is at the end of your program, so it terminates the program cause there's no following lines of code
program is doing what you made it to do lol Firstly, the throw is inside a while loop. What I'm wondering is why the crap it isn't continuing the while loop, opposed to what it does now; which is ends the program. It should not be ending the program, it should be throwing an error, catching it, and then going back to the while loop. On May 28 2009 09:44 RaGe wrote: wow i get more and more convinced you have no idea what you're doing and just copy pasted shit or something
i mean, your catch block is:
catch(StringTooLongException e){ System.out.println(e.getMessage()); System.out.println("Exception caught! Ending program."); }
you even print that you're ending the program and you dont want it to end the program? Oh noes, I has a random print line that hasn't been changed from a previous version. Printing text doesn't end a program. ... (At least not this one) Show nested quote + Rage posts Maybe you should stop being so defensive and read the fucking solution for a change.
I can't even program and I understand what Rage says. Exception thrown = goto catch. Your friend doesn't address this point at all. So Rage says l2read.
|
|
|
|