Results 1 to 3 of 3
  1. #1
    aRTx is offline Member
    Join Date
    Mar 2009
    Posts
    27
    Rep Power
    0

    Question 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).

    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);
      }
    }
    My result until 8 are:
    [CODE]x y
    1 10
    2 9
    3 90
    4 90
    5 900
    6 900
    7 9000
    8 9000
    9
    /CODE]

  2. #2
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    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!

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. is IntelliJ is slow in IDE ??
    By adusumalli in forum IntelliJ IDEA
    Replies: 3
    Last Post: 12-16-2008, 05:44 PM
  2. want to know why netbeans is slow
    By rakesh_n_mehta in forum NetBeans
    Replies: 3
    Last Post: 11-03-2008, 05:07 PM
  3. Slow all of a sudden.
    By Josh @ Dreamland in forum New To Java
    Replies: 3
    Last Post: 08-19-2008, 06:02 AM
  4. slow JasperReport
    By bbq in forum Advanced Java
    Replies: 3
    Last Post: 02-11-2008, 08:34 AM
  5. eclipse very slow
    By katie in forum Eclipse
    Replies: 2
    Last Post: 11-05-2007, 10:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •