Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!

Dave Tolls

Rancher
+ Follow
since Sep 04, 2013
Cows and Likes
Cows
Total received
47
In last 30 days
0
Total given
0
Likes
Total received
757
Received in last 30 days
4
Total given
24
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dave Tolls

Well, you had the picker working with LocalDate, so you'll need to show us what you have now, especially the conversion between LocalDate and ZonedDateTime.
1 day ago
You revert to using LocalDate for the picker, then convert to ZonedDateTime when you create the persistence object.
2 days ago
Can't you take the date as a LocalDate and convert to a ZonedDateTime?

There are at methods to help with this (eg atStartOfDay).
2 days ago
Well, for this one remove the '+'.
2 days ago
What does your AsyncTask look like?
How is it called?
3 days ago
What is the app the users are using, and do you have control over that?
3 days ago
In the second example output.toString() will throw a NullPointerException, not return a null.

In the first example, the System.out line will print nothing at all.
3 days ago
Though Carey has shown how to di the parsing, one thing I will say is that "it doesn't work" is not much use to us.
You need to show us the problem code, and what exactly is going wrong, that way we can help with any misunderstandings you may have with how the code is supposed to work.
6 days ago


This may not be your immediate issue, but the above says to me "if the chosen language is "En" then use the "ar" location and language, otherwise use the "en" ones".
I assume that's not correct.
1 week ago
Which IDE also helps.
For example, Eclipse has a tab called "Problems" which lists all the errors in your project, in addition to the "hover" ability mentioned above, and clicking on the red blob in the left margin.
1 week ago

Campbell Ritchie wrote:In OP's question however a space was removed and a different object was returned.



Ah.
My eyes completely missed that there was a space at the start of the second string!
I thought they were both the same...

Hopefully I haven't confused things!

Campbell Ritchie wrote:
To answer the actual question:- look at the JLS (=Java┬« Language Specification) for the definiton of compile‑time constants (officially called, “constant expressions”). You will see that method calls are not permitted in any of the expressions. It tells you that...

Constant expressions of type String are always "interned" so as to share unique instances, using the method String.intern.

But the second instance of "abc" isn't a constant expression, being created via a method call, its actual value is only known at runtime, and it isn't put into the String pool. If you want that == te‍st to return true, try changing the second line to read,



I'm not sure this is actually relevant.
There's no reason at all that the stripLeading method couldn't return the original String if there are no leading spaces.
It's a case of "implementation detail" as to whether you get the original String back or a new one.



And, of course, even if it did it this way you shouldn't be relying on that (unless it's documented as such) because (being an implementation detail) it could change between versions.
The Java compiler does not use the type of the return value to determine what method to apply.
So, as far as it is concerned, the following two methods would be classed as the same:

as your code shows, in fact.

Consequently, when you make a call to fly(<some int value>) the fact you are assigning the result to an int plays no part in the compiler deciding which method to apply.  It picks solely based on the method name and the given parameters.

So your code does show it picking the correct method within the rules of the compiler, it's just that the code itself is incorrect.
1 week ago
MyEx extends Exception, which means that it needs to be handled (as the compiler error says).
It can be handled either by catching it in a catch block, or by changing the method signature to show that it throws the exception.

Your second code works because you have told Java that the exception is being passed out of the method rather than being handled inside the method, by changing the signature to note the exception thrown.
2 weeks ago
Definitely use the methods provided by the request object.
There should be no reason to manually split the URL in order to get the parameters.
2 weeks ago