Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  What's the most helpful feature in Java 5 and why?  (Read 1479 times)
0 Members and 1 Guest are viewing this topic.
Offline K.I.L.E.R

Senior Devvie




Java games rock!


« Posted 2005-01-16 07:44:09 »

Enums. Cheesy

Sun had done a surprisingly awesome job with them.
In fact, there are a lot of nice ways you can implement Java enums to create new design methodologies within your programs.

In fact, I prefer Java enum implementation over all the other languages implementation.

Enums with intelligence. Smiley

I've just been reading about them now in depth because how I've been using enums is the same as in any other language.

However, I had a great idea. Call it a brain fart.

I've been reading Sun's explanations and when I noticed this in particular:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public enum Operation {
    PLUS, MINUS, TIMES, DIVIDE;

    // Do arithmetic op represented by this constant
    double eval(double x, double y){
        switch(this) {
            case PLUS:   return x + y;
            case MINUS:  return x - y;
            case TIMES:  return x * y;
            case DIVIDE: return x / y;
        }
        throw new AssertionError("Unknown op: " + this);
    }
}


I came to the conclusion that if you were to right a scripting language and pass it into Java, you can have values passed into Enums to automate the work real nice and neat.

So what do you guys think?

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2005-01-16 07:51:13 »

Enum implementation is pretty neat although the Enum pattern (which is basically the same) has existed a while. I'm not sure I've used them in enough anger to see any significant difference between using the two. (apart from switch blocks)

Kev

Offline K.I.L.E.R

Senior Devvie




Java games rock!


« Reply #2 - Posted 2005-01-16 08:09:50 »

You can't be serious?
When you say the Sun example pattern has been out for a while do you mean it's been used in languages like C++?

I've never seen anyone use enums like Sun's example has and I've done quite a bit of C++.


Quote
Enum implementation is pretty neat although the Enum pattern (which is basically the same) has existed a while. I'm not sure I've used them in enough anger to see any significant difference between using the two. (apart from switch blocks)

Kev

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2005-01-16 08:11:23 »

No, I meant in Java.

I've been using Enum Pattern classes in Java for quite a few years.

Kev

Offline K.I.L.E.R

Senior Devvie




Java games rock!


« Reply #4 - Posted 2005-01-16 09:29:49 »

Quote
No, I meant in Java.

I've been using Enum Pattern classes in Java for quite a few years.

Kev


Oh. Though they wouldn't be as neat as if you used enums. Wink

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Offline princec

« JGO Spiffy Duke »


Medals: 439
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2005-01-16 09:44:47 »

There's only a teeny bit of syntactical sugar for enums. The feature I like most is static import. Saves lots of ugly code.

Cas Smiley

Offline Chman

Junior Devvie




Nothing more that... Java games are cool !


« Reply #6 - Posted 2005-01-16 10:10:17 »

Static import for me... Makes the code nicer (especially using LWJGL Tongue).

Chman
Offline Raghar

Junior Devvie




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #7 - Posted 2005-01-16 18:01:43 »

Nano timer in the standard library, of course.
Possibility to have a some nano timer at any Java2 SE platform is very important.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (17 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (86 views)
2014-12-05 12:39:02

SHC (97 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!