Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: difficult program

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Location
    Ireland
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default difficult program

    help me i don't know what
    Attached Files Attached Files


  2. #2
    Junior Member
    Join Date
    Apr 2010
    Location
    Italy
    Posts
    15
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default Re: difficult program

    Hi Fordy252,
    I can't open your file.
    Bye

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,237
    Thanks
    176
    Thanked 817 Times in 760 Posts
    Blog Entries
    5

    Default Re: difficult program

    Please provide more details - error messages, expected and observed output, along with the source code in the post itself (between the [highlight=java][/highlight] tags). And...recommended reading: How To Ask Questions The Smart Way

  4. #4
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: difficult program

    Your break statements will exit the for loops prematurely.

    if (num == distinct[x])

    At this point, distinct[x] is emtpy for all indexes in the array.

  5. #5
    Junior Member
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: difficult program

    I can't open your file.........

  6. #6
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: difficult program

    Quote Originally Posted by javapenguin View Post
    Your break statements will exit the for loops prematurely.

    if (num == distinct[x])

    At this point, distinct[x] is emtpy for all indexes in the array.
    It's not empty but 0 and what if one of element is equal to 0 in OP's numbers array?
    else
    				distinct[disNumCount] = num;//if the number is not there, save it 
    				disNumCount++;
    				break;
    Why do you need to make it nested loop if it will break exactly after one iteration?

  7. #7
    Member Abhilash's Avatar
    Join Date
    Jun 2014
    Location
    Kolkata, West Bengal, INDIA
    Posts
    103
    My Mood
    Busy
    Thanks
    5
    Thanked 9 Times in 9 Posts

    Default Re: difficult program

    distinct array is empty man!

  8. #8
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,491
    My Mood
    Mellow
    Thanks
    152
    Thanked 610 Times in 597 Posts

    Default Re: difficult program

    This thread is ancient. Please check the dates, and if the oldest response in the thread is >1 month, it's essentially dead. There may be a reason to revive it, but they are rare.

    Otherwise, welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Thread closed.

Similar Threads

  1. [SOLVED] Java program to invert a string and display the last enter key in uppercase
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: August 27th, 2009, 02:33 AM