aspose file tools
The moose likes Beginning Java and the fly likes Question about enums and enhanced for Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Question about enums and enhanced for" Watch "Question about enums and enhanced for" New topic
Author

Question about enums and enhanced for

Mihai Lita
Ranch Hand

Joined: Jan 11, 2011
Posts: 36

Hello,
I have the following code:



My first question is: does it matter that the statement is written after the constructor of the enum?
Second question: does the enhanced for automatically put "\n" after the end of each Sop ?

Thank you,
Mihai
Loic Beylot
Greenhorn

Joined: Mar 24, 2011
Posts: 8
Hello,

Mihai Lita wrote:My first question is: does it matter that the statement is written after the constructor of the enum?

No it doesn't matter, you can declare an variable after using it,

Mihai Lita wrote:Second question: does the enhanced for automatically put "\n" after the end of each Sop ?

No, but it will allways go to the next line:
Terminate the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').
http://download.oracle.com/javase/1.3/docs/api/java/io/PrintStream.html#println%28%29
Mihai Lita
Ranch Hand

Joined: Jan 11, 2011
Posts: 36

Thanks,
I was right in my face but coudln`t see the println!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
. . . and welcome to the Ranch
Loic Beylot
Greenhorn

Joined: Mar 24, 2011
Posts: 8
You are welcome... and thanks
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12952
    
    3

Mihai, when you copy code from a book or some other source, please mention where you copied it from (QuoteYourSources). Isn't this from Head First Java? (I vaguely recognise it...).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Mihai Lita
Ranch Hand

Joined: Jan 11, 2011
Posts: 36

it`s from KB SCJP exam.
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12952
    
    3

Ah, the SCJP Study Guide, also called "K&B" after the names of the authors (Kathy Sierra and Bert Bates).

Thanks.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Question about enums and enhanced for
 
Similar Threads
use of " this " ...
Enums...
Enum overloaded constructer
confusion regardind enum and constructors
Enum programs are not compiling in java5.0 compiler?