Results 1 to 16 of 16

Thread: java arrays

  1. #1
    miko5054 is offline Member
    Join Date
    Mar 2010
    Posts
    50
    Rep Power
    0

    Default java arrays

    im tiring to create a program that will receive 10 int arrays
    and if tow numbers are equal i need to print them only once

    example

    {125161548}

    print

    {125648}

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Cool! Do you have a question?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    miko5054 is offline Member
    Join Date
    Mar 2010
    Posts
    50
    Rep Power
    0

    Default

    ??

    i don't knew how the check if the num are equal
    ??????

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    How would you do it on a piece of paper?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    miko5054 is offline Member
    Join Date
    Mar 2010
    Posts
    50
    Rep Power
    0

    Default

    on eclipse

    public class Ex7Qu3 {

    public static void main(String[] args) {
    int num3;
    int[] num1 = new int[10];


    for (int i = 0; i < num1.length; i++) {

    num1[i] = (int) (Math.random() * 10);
    System.out.print(num1[i]);

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Wow, when I do that on a piece of paper, I'd take the first number and print it, then strike all other occurances of that number, then I'd take the next number and do the same with that one. But that might just be me.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  7. #7
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Yeah, I think I'd just take a look just before I wrote it down to see if it's on the list of numbers I've written down already.

    -Gary-

  8. #8
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Yup, that's possible too, just that you cannot really look what you have written from a program, unless you've stored the written numbers somewhere ;)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  9. #9
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Quote Originally Posted by PhHein View Post
    Yup, that's possible too, just that you cannot really look what you have written from a program, unless you've stored the written numbers somewhere ;)
    Exactly. Which, in this case, I have. :D

    -Gary-

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,304
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by PhHein View Post
    Yup, that's possible too, just that you cannot really look what you have written from a program, unless you've stored the written numbers somewhere ;)
    Duh, I have LinkedHashSets in my brain ;-)

    kind regards,

    Jos (<--- forgot to take his pills)

  11. #11
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Quote Originally Posted by JosAH View Post
    Duh, I have LinkedHashSets in my brain ;-)
    Doesn't that hurt? :p
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,304
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by PhHein View Post
    Doesn't that hurt? :p
    Terrible pains, day and night, don't get me started ...

    kind regards,

    Jos (I also have LinkedLists in my body, yuck! ;-)

  13. #13
    miko5054 is offline Member
    Join Date
    Mar 2010
    Posts
    50
    Rep Power
    0

    Default

    code please :)

  14. #14
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Quote Originally Posted by miko5054 View Post
    code please :)
    No. This forum isn't for other people to do your homework for you. You've actually gotten two completely valid and helpful answers in this thread already.
    Wow, when I do that on a piece of paper, I'd take the first number and print it, then strike all other occurances of that number, then I'd take the next number and do the same with that one. But that might just be me.
    Yeah, I think I'd just take a look just before I wrote it down to see if it's on the list of numbers I've written down already.
    Writing the code is your job. Show us your best effort, and we may be able to help you find your mistakes.

    -Gary-

  15. #15
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    EDIT: what Gary said.
    Last edited by PhHein; 03-18-2010 at 04:57 PM. Reason: duplicate answer removed.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  16. #16
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,304
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by miko5054 View Post
    code please :)
    Java Code:
    Object ptr= 1/null; // point to everything
    ptr= null; // release everything
    kind regards,

    Jos

Similar Threads

  1. Java arrays (not sure if this question is advanced)
    By aga010607 in forum Advanced Java
    Replies: 1
    Last Post: 11-24-2009, 01:43 PM
  2. Indexing java arrays with string
    By Jackblue in forum Advanced Java
    Replies: 10
    Last Post: 09-30-2009, 01:48 PM
  3. arrays in java
    By mayhewj7 in forum New To Java
    Replies: 4
    Last Post: 12-17-2008, 03:48 AM
  4. Help needed with java arrays code
    By d24706 in forum New To Java
    Replies: 2
    Last Post: 03-07-2008, 01:11 AM
  5. Arrays in Java
    By hiranya in forum New To Java
    Replies: 3
    Last Post: 07-30-2007, 09:10 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
  •