Results 1 to 3 of 3
Thread: Why JAVA is so slow?
- 05-11-2009, 06:41 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 27
- Rep Power
- 0
Why JAVA is so slow?
Hi,
I'm trying to compute this problem but it take so long with java
Can anyone RUN it and show the result pls (if you have a good computer).
My result until 8 are:Java Code:class CountMirror { public static void main(String[] args) throws Exception { int count = 0; for(int j=100000000; j<=999999999; j++) { int num = j; String str = Integer.toString(num); String reStr = ""; for(int i=0; i<9; i++) { reStr = str.charAt(i) + reStr; } int revInt = Integer.parseInt(reStr); if(revInt==j) { count = count + 1; } } System.out.println (count); } }
[CODE]x y
1 10
2 9
3 90
4 90
5 900
6 900
7 9000
8 9000
9
/CODE]
- 05-11-2009, 07:58 AM #2
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
Heck man, your crazy... now that I have that out of my system.
You are trying to count through almost 1billion numbers. of course it will take forever. Also, you are not printing anything out in the for loop. It's not going to do what you want. Period.If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
- 05-11-2009, 10:19 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Just try to write down your logic on a paper with the each number you want to workout in the loop.
Similar Threads
-
is IntelliJ is slow in IDE ??
By adusumalli in forum IntelliJ IDEAReplies: 3Last Post: 12-16-2008, 05:44 PM -
want to know why netbeans is slow
By rakesh_n_mehta in forum NetBeansReplies: 3Last Post: 11-03-2008, 05:07 PM -
Slow all of a sudden.
By Josh @ Dreamland in forum New To JavaReplies: 3Last Post: 08-19-2008, 06:02 AM -
slow JasperReport
By bbq in forum Advanced JavaReplies: 3Last Post: 02-11-2008, 08:34 AM -
eclipse very slow
By katie in forum EclipseReplies: 2Last Post: 11-05-2007, 10:20 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks