3 Replies - 243 Views - Last Post: 05 May 2013 - 11:24 AM Rate Topic: -----

#1 beginnerflow.java  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-April 13

enum type

Posted 04 May 2013 - 07:21 AM

Basically, I am creating an inventory report for grocery items and household items and I need to implement the GroceryType as an enum type and have it print out in the inventory report when the user is asked to do so.


	public enum GroceryType 
	{
	    FRESH,FROZEN,CANNED,REFRIGERATED,DELI,PACKAGED
	}
	



but i am lost as to what to do next.

*Edited: fixed code tags

This post has been edited by pbl: 04 May 2013 - 02:20 PM

Is This A Good Question/Topic? 0
  • +

Replies To: enum type

#2 Gungnir  Icon User is offline

  • Your Imaginary Friend

Reputation: 152
  • View blog
  • Posts: 527
  • Joined: 21-May 11

Re: enum type

Posted 04 May 2013 - 07:33 AM

Well, you need to close your statement with a semi-colon, but besides that this enum is fine.
public enum GroceryType
{
    FRESH,FROZEN,CANNED,REFRIGERATED,DELI,PACKAGED;
}



Quote

and have it print out in the inventory report when the user is asked to do so.

I'm afraid that you'll have to write some functionality before we can help you with that functionality. I would suggest starting with some System.out.print() to print directly to the console. I'm assuming you've covered that, as it's the Hello World of Java.

Further Reading:
- Oracle Docs > Basic I/O [Tutorial]
Was This Post Helpful? 1
  • +
  • -

#3 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 822
  • View blog
  • Posts: 2,529
  • Joined: 29-July 11

Re: enum type

Posted 04 May 2013 - 05:17 PM

You don't need to end with a semi-colon.
Was This Post Helpful? 3
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: enum type

Posted 05 May 2013 - 11:24 AM

View Postfarrell2k, on 04 May 2013 - 08:17 PM, said:

You don't need to end with a semi-colon.

Yes this is to help the GUI generator designers
they don't have to validate that the enum is terminated and to add the ;

it is like the initialization of array

int[] x = {1,2,3,4,5,};

you can have an extra , at the end of the list without a problem
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1