Gabriel Beres

Ranch Hand
+ Follow
since Sep 09, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gabriel Beres

Hey,

I understand why mutating instance variables is a bad thing.
But what about mutating state inside a function? To my knowledge, variables inside the function are allocated in the stack and not in the heap, therefore they are not objects of any concurrency issue.

Scala and other functional languages say you should not mutate any state. Why it is so?
5 years ago
What do you mean by stateless code?
Does that mean i have to completely give up on OO?
5 years ago
Hi,

I often hear that Scala is much better language to utilize multi core processors.
Are they referring to the Akka library, or the capability of doing functional programming? In my understanding, even if you write your code in functional way(without side effect and referentially transparent), it does not utilize multi core processors out of the box.

So what is the real deal here?

5 years ago
Hi,

Why would somebody choose JEE with app server over tomcat+Spring?
Think of it like an interview question.

Thanks
Hi,

I want to collect some advanced static metrics in my code like

-Number of classes that implement a specific interface
-Number of methods that has a specific annotation

and stuff like that.

Can you recommend some tool or eclipse plugin, which does that?

Thanks
5 years ago

Mike Simmons wrote:The patterns given previously probably do work, but not in a split(). That's because in split() you need a regex for the delimiter, not the content between the delimiter. Instead, the regexes given are designed to be used with a Matcher, where you find() each new element. But to do it with split() , you could define a regex that uses lookahead and lookbehind, to find a location in the string that's after a number and before a letter:



Ohh, good point.
I think i'll just call split("T), and go from that. Letter T is always the secound character.
6 years ago

fred rosenberger wrote:can you better define "a number"?

is -1 possible?

how about 2.839?

how about e or i?

how about 1.189 * 10^14?

all of the above are valid numbers in various situations.



Any integer like 7 and 3443434
6 years ago

Jeff Verdegan wrote:

Gabriel Beres wrote:None of these patterns actually work



That's not surprising, considering you still haven't told us your exact rules.

Also note that ItDoesntWorkIsUseless(⇐click).




I would like to make an array from the following string in java:

PT 3PT 6PT 7PT 8PT 9PT 10PT 11PT 13PT 14PT 15PT 16PT 17PT 19PT 20ST 6ST 7

like

0 = PT3
1 = PT6
2 = PT7
...



That's it. two letters like PT, and a number after
6 years ago
None of these patterns actually work
6 years ago

Ramesh Pramuditha Rathnayake wrote:if you want "PT3, PT6...., PT10, PT11,..." I think regex is the best..!!



What would be the pattern for that?
6 years ago
Hi,

I would like to make an array from the following string in java:

PT 3PT 6PT 7PT 8PT 9PT 10PT 11PT 13PT 14PT 15PT 16PT 17PT 19PT 20ST 6ST 7

like

0 = PT3
1 = PT6
2 = PT7
...

What is the simplest way to do that?

Thanks
6 years ago

Jeff Verdegan wrote:If it's null, then instanceof will always be false. There's no way to tell if a null was supposed to be an Integer or a Double or a Date or a JPanel, unless you're in the body of a method that has that type (or a subtype) as an arg. There is no such thing as a null Integer or a null Double.

If you want to distinguish a null that would have been an Integer from a null that could have been a Double, you need either context or metadata. The null itself is not enough.



Thanks this information was usefull. I completely forgot NULL has no type. Let's pretend i pass the type to my generic method too. The question remains the same. Shall i write this method, or exists somewhere?
6 years ago
Hi!

I want to ensure that if a Double or Integer is null, it is converted to 0.0 and 0, thus preventing nullpointer.

I'm thinking about a generic method that takes a Number, and checks if it is Double or Integer with instanceof.
Then it checks for null and if it is, it returns new Double(0.0) or new Integer(0). The method would have a return type Number in this case.

I wonder if such method already exists somewhere in java or apache commons. So far i could not find anything like this.

Thanks

6 years ago
Hi,

I'm implementing a converter application which reads files in one format, then converts and exports in another format.
I need to make this fail save, so there should be no partly read, and partly written entries in the input/export files. It should even maintain consistent state in case of JVM shutdown. (iex, returning after restart of JVM from last successfully written message)

Any suggestion how to do this?

Thanks,
B.
7 years ago