R. Grimes wrote:s.isNullOrEmpty()?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:
R. Grimes wrote:s.isNullOrEmpty()?
That would cause a NullPointerException if s is null, because you can't call any (non-static) methods on a null reference. It would be better if an isEmpty(String) method made it into a java.util.Strings utility class, like how they introduced java.util.Objects in Java 7.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
As they are not implemented by this method, for example?Abhay Agarwal wrote: . . . not implementing these sorting algo in any utility class in Java API.
joe taka wrote:What feature that you wished Java 7 had that isn't in?
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:Unsigned bytes.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote: But, asking for "octets" of any kind would be adding a new data type to the language. Java already has bytes. I want the same primitive, by the same name, just without a sign.
Pat Farrell wrote:I don't see how you could have byte[] or Byte[] and have it either be signed or unsigned.
"Il y a peu de choses qui me soient impossibles..."
Paul Clapham wrote: it's when you use it that you can treat it as signed or unsigned. So it isn't a datatype, it's some kind of annotation which says "treat the bytes as unsigned in this calculation".
Stevens Miller wrote:You know, like C++ has...and C has...for about the last seven-hundred billion, trillion years.
Pat Farrell wrote:
Paul Clapham wrote: it's when you use it that you can treat it as signed or unsigned. So it isn't a datatype, it's some kind of annotation which says "treat the bytes as unsigned in this calculation".
What other datatypes use annotations to control things like overflow or the results of addition.
I think you'd have to have the annotation on the declaration and every usage, which will quickly become way ugly.
Leopold Kronecker wrote:God created the natural numbers. All else is the work of man.
"Il y a peu de choses qui me soient impossibles..."
From Psalm 62: 9.God wrote:Surely men of low degree are vanity,
and men of high degree are a lie:
to be laid in the balance,
they are altogether lighter than vanity.
But it used 16‑bit ints andPat Farrell wrote: . . . The earliest known records of C come from 1969. Its barely 45 years old.
…was truncated by the cast to 45seven-hundred billion, trillion
Campbell Ritchie wrote:I agree that unsigned bytes would have been a lot easier to work with.
"Il y a peu de choses qui me soient impossibles..."
R. Grimes wrote:I"m a simple guy. My wishes are small, since I don't think I'll ever come close to using the full power of Java as it already exists. But, I really hate having to do repetitive stuff like
There's already equalsIgnoreCase. How about equalsIgnoreWhitespace? Or, equalsIgnoreCaseAndWhiteSpace?
Also, I hate having to to check strings for both null and empty. So, instead of
s.isNullOrEmpty()?
Yes, I know there are Util packages out there that does that kind of stuff, but this is pretty basic stuff and should come with the basic JDK. Simple things like this can remove a lot of clutter. I'm always amazed at how Java makes hard things simple, and simple things overly complex or verbose to achieve.
Ron
Stephan van Hulst wrote:I still want a method that can tell me whether a String can be parsed to an int. I also want methods that can convert primitive arrays to collections and vice versa.
I also think having annotations that indicate preconditions and invariants would be nice. I believe an annotation @NotNull is coming up, but I can picture that it would be nice to be able to do something like this:
Instead of:
"Il y a peu de choses qui me soient impossibles..."
"Il y a peu de choses qui me soient impossibles..."
Paul Clapham wrote:Yes, that's what a WeakReference does. When its referent is eligible for garbage collection, the get() method will return null instead of the referent. At least, that's how I understand it.
Although, reading the API docs, it appears that there might be a gap between the listener becoming weakly reachable and the garbage collector noticing that, and during that gap perhaps the listener might be called superfluously. That was what you meant, wasn't it?
But I don't think you can avoid that because nothing in the language enables you to interact with the garbage collector any more tightly than what WeakReference already does.
Which I guess gets us back to what you originally asked. It seems you want a deterministic interface with the garbage collector, instead of just allowing the garbage collector to lounge around in the background doing its own thing.
However if you had a garbage collector which worked via reference counting, it wouldn't be that hard to do what you described VB 6 as doing. It's been decades since I used VB, and back then it was VB 5, but I'm pretty sure it used reference counting, since I recall discussions about having to write code to clean up objects with circular references.
"Il y a peu de choses qui me soient impossibles..."
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|