Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: printing with count on linkedlist-JAVA error correction

  1. #1
    heys is offline Member
    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Default printing with count on linkedlist-JAVA error correction

    private void displayFlowers() {

    int count = 0;

    if(start == null) { System.out.println("\n List is empty !!"); } else { Node tail = start;

    while(tail!= null) {keep boolean[] counted= new boolean[getName.length];2 for(int i=0;i<name.length;i++)2 { boolean isUnique = false;2 and 1 if(!counted[i]) {isUnique=true; count=1; counted[i]=true; for(int j=i+1;j<name.lenght;j++) {if(name[i]==(name[j])) {count++; counted[j]=true;} } } if(isUnique) {System.out.println(name[i]+"- "+count+"\n");}}} boolean isDistinct=false;1 Node name=start;1

    while(name!=tail){1 /* Node prev=tail.getnext; while( tail.hasNext()) ; if(name==prev)

    Next=tail.next(); if(prev==next); dups++; previous=next;*/ /* if(name.equals.tail.getNext());1 1 name=+count;1} else{1 isDistinct|=!name.getItem().equals(tail.getNext()) ;1 isDistinct=true; name=name.getNext();}1 System.out.println("name" +isDistinct);/I don't think that this is correct.1 REMOVE if(isDistinct)isDistinct++;1*/ KEEP IF DOESN"T WORK tail=tail.getNext();} System.out.println("Flower number("+count+") , node value="+tail.getItem().getName()+"\tFlower Color "+tail.getItem().getColor()+"\tHas Thorns " +tail.getItem().isThorns()+"\tSmell: "+tail.getItem().getSmell()); count++; * tail /= tail.getNext();

    }}}I have a linked list and I am trying to print how many from each node I have...For example..If I have entered the item Fries 5 times I would like for it to print 5-Fries in my code. The printing portion is the only thing I am needing help with.
    Last edited by heys; 07-26-2013 at 05:13 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: printing with count on linkedlist-JAVA error correction

    Please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    Also go through the Forum Rules, particularly the second paragraph. The other thread you started in Advenced Java has been closed.

    db
    heys likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: printing with count on linkedlist-JAVA error correction

    I also recommend that you go through Code Conventions for the Java Programming Language: Contents

    As it stands, adding code tags isn't going to make your code much more readable.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: printing with count on linkedlist-JAVA error correction

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

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

    Default Re: printing with count on linkedlist-JAVA error correction

    Cute code formatting; if you really want that nobody is going to read your code, you're doing a fine job; sheeez ...

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,049
    Rep Power
    6

    Default Re: printing with count on linkedlist-JAVA error correction

    In all the horribly formatted Pascal and C code I have seen in my life, I have NEVER seen it this bad.

    (that may seem oddly specific, those are languages in which it is incredibly easy to "naturally" write poorly formatted code :) )
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: printing with count on linkedlist-JAVA error correction

    Quote Originally Posted by gimbal2 View Post
    In all the horribly formatted Pascal and C code I have seen in my life, I have NEVER seen it this bad.

    (that may seem oddly specific, those are languages in which it is incredibly easy to "naturally" write poorly formatted code :) )
    I always enjoyed the IOCCC; I don't know if it still exists but each year had fine examples of the most horrbile 'non-formatted' and highly obuscated code ...

    kind regards,

    Jos (sigh, those were the days)
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,647
    Rep Power
    5

    Default Re: printing with count on linkedlist-JAVA error correction

    I'm wondering what the 2 and 1, and the other 1's scattered thru out the code are for.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

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

    Default Re: printing with count on linkedlist-JAVA error correction

    Quote Originally Posted by jim829 View Post
    I'm wondering what the 2 and 1, and the other 1's scattered thru out the code are for.
    Don't bother, it is utmost nonense; it is full of it ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. count every 45 records and prfix the count number
    By dkr786 in forum New To Java
    Replies: 8
    Last Post: 02-15-2013, 07:31 PM
  2. Help with deleting/printing linkedlist<object>
    By delvinv in forum New To Java
    Replies: 3
    Last Post: 05-02-2012, 09:43 AM
  3. Replies: 18
    Last Post: 08-09-2011, 08:08 AM
  4. Replies: 5
    Last Post: 11-22-2008, 01:34 PM
  5. Please help me with LinkedList in Java
    By lenny in forum New To Java
    Replies: 2
    Last Post: 07-31-2007, 02:24 PM

Tags for this Thread

Posting Permissions

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