Make a file called Main.java place my code in there, compile, run.
Or replace
withCode:public class Main {
(which is what your file is called)Code:public class IO{
Printable View
wait wth, epic fail. You didn't change anything.... Trying to trick me or something? You just deleted the extra spaces..... That doesn't make any difference, wth was the point..
Dude, this is just a class. You don't ever have to even use this code again.. So who cares if there are extra spaces. As long as it works, thats all it matters...
In Dr.Java, it can already properly space it for me.
Just do ctrl + a
and click on tab.
Code:public static int getInt(String str) {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
try {
return Integer.parseInt(str);
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
return 0;
}
Well, first its practice, if you use bad coding practice on one file, you might use it on another.
Second if you ever need to review that file or implement something else, it will take more time to do(probably just some seconds lol).
Third people wont just copy/paste what you posted, they will try to understand it before use, so using proper programming practice is better.
---------
On a side note, man, calm down, accept what people say or dont post it, dont expect everyone to say "I loved it, thanks" because this is very hard to get.
Also you started the flamming on your own thread :\
Just some tips
- allow the method to throw the exception and catch up where it's called.
- Don't use JOptionPane.showinputdialog for getting a yes/no answer, use showOptionDialog.
- Why bother using compareTo when you can do equals
-You should learn to instantaneously create a variable and set a value to itCode:String word;
word = IO.getString("Enter word") ;
- Why do we have system.out.println() everywhere.. Use logger and set the logging level to finest if you want to debug the class so other people using your class won't have to see all the things you're printing to the screen (im assuming you want to debug it o__o)
- Assuming you want to make DoAgain Singleton
public Doagain(){}
Should be private
- Your println method is redundant.
Okay I found out how to do the Do command.
Goodluck~