File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Enumerable.Range() in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Enumerable.Range() in Java?" Watch "Enumerable.Range() in Java?" New topic
Author

Enumerable.Range() in Java?

Keith Flo
Ranch Hand

Joined: Nov 29, 2005
Posts: 128

This is a kinda silly question ... but here goes ...

Is there an equivalent to Enumerable.Range() method in Java? The .Net framework has an method that takes int start and int count arguments and returns a sequence of intergers numbers within that range. Does a similar method exist in Java?



PS: Yes ... I know I can easily write a similar static method myself that takes the same arguments and returns an array (or preferably a List) but I was just wondering and Enumerables are used a lot in Linq and the Java libraries and the .Net framework have soooo many similarities.


kf
SCJP 5.0 (preparing for SCWCD)
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Keith:

Enumerations in Java (1.5+) are real classes, not integers.

John.
Keith Flo
Ranch Hand

Joined: Nov 29, 2005
Posts: 128

John,

I'm wondering if there is a similar method in Java ... I know the naming will be different ... I dont know why MS always changes the names of well known structures and patterns but they always do ...

John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Keith:

No, there isn't. I did try looking in a number of promising classes, though (Integer, Arrays, Array).

John.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
[pedantic mode]By Enumerations, I presume you mean enums?[/pedantic mode]
Keith Flo
Ranch Hand

Joined: Nov 29, 2005
Posts: 128

John,
Thanks for your response ... I couldn't find anything similar ... just wondering if it might exist somewhere..


Campbell
... no I dont mean Enums .... rather in CSharp/.Net the IEnumerable interface and the Enumerable class define a 'sequence' ....

but you likely already know this ...

Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3007
    
    9
Keith Flo wrote:Campbell
... no I dont mean Enums .... rather in CSharp/.Net the IEnumerable interface and the Enumerable class define a 'sequence' ....

but you likely already know this ...

No, I'm pretty sure Campbell was responding to John de Michele:
John de Michele wrote:Keith:

Enumerations in Java (1.5+) are real classes, not integers.

John.

Enumerations in Java are interfaces, not classes, and have been there since 1.0. As Campbell said, this was probably a reference to enums, not Enumerations.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Mike:

Yes, I meant 'little e' enums. Unfortunately, the rules of English require capitalizing the first word, which makes it hard to accurately describe stuff in computer languages sometimes . And actually, the name of that interface is Enumeration.

John.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3007
    
    9
Regardless of capitalization, there's a big difference between an Enumeration and an enum. Count the letters. You keep saying "Enumeration" when you must mean "enum". Please, stop. An Enumeration is a different thing entirely. Look it up. None of your statements here make any sense when you say Enumeration - but they do make sense if you say enum.

And Keith - no, sorry Java doesn't have anything like that.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Mike:

The term 'enum' is short for enumerated type or enumeration: Enumerated Type. I am aware of the difference between the Enumeration interface and an enum. Sun should have named the Enumeration interface something else (as implied by their javadoc), maybe 'Iterator'.

John.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enumerable.Range() in Java?