Timothy Sam

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

Recent posts by Timothy Sam

Paweł Baczyński wrote:First, if you need to sort in reverse order, don't use thenComparing(). Use reversed() directly on your original comparator.
Second, if the compiler can not determine the type of s in the lambda you can specify it.

So you'll have
.sorted(Comparator.comparingDouble((Transaction s) -> s.getAmount()).reversed())

It would be even nicer to use a method reference:

Hi Paweł,

Perfect! Thank you!
3 years ago

I'm trying to sort a List in reverse order. I can do the code below without a problem:

and that works, but when I try to chain with:

It doesn't work and compiler says it could not resolve the method getAmount? What am I missing here?

Thanks in advance!

Here's my full source

3 years ago
My IDE suggests that this can be converted into a Lambda expression.

I only use it like this...

I know that I'm supposed to operate on an Interface, which is function in this case. It's not that I'm being lazy, but could someone please show me how it's done?

Thanks in advance!
3 years ago
That looks super elegant! Thanks! I thought I should always wrap nullables with Optional. Would you have any opinions on that?
3 years ago

I'm trying to figure out if there's a more elegant way of doing this with streams rather than checking separately through an if-else statement? How would you rewrite this code? Thanks in advance!

3 years ago
Topic = Multiple subscribers
Queue = One consumer, deletes the messages once sent?

So, say I have 3 consumers in a topic.

1. If only one of them is able to receive the message, is the message queue and waits for the other two consumers to consume it?
2. What happens once all consumers in a topic consumes a message? Is the message deleted?

Hi, I'm trying to collect some questions here in the forums to make a tutorial out for in my blog. I tried to answer your question here in this link.

8 years ago
Thanks Tim H.

From the Sony Ericsson Developer World site, it's funny that they would mention motion gaming support and yet not mention JSR-256 in the list of their supported JSR's and API's.



* CLDC 1.1
* WMA (JSR-120)
* MMAPI(JSR-135)
* Mobile 3D(JSR-184)
* Java Technology for the Wireless Industry(JSR-185)
* File/PIM(JSR-75)
* Mascot Capsule V3
* MIDP 2.0(JSR 118)
* Nokia UI API 1.1

This website mentioned JSR-256 support


Mobile Sensor API (JSR-256)

Thanks again.
8 years ago
Hi guys,

Is there an API in Java to take advantage of a phone's motion sensor feature? I want to try especially on Sony Ericsson's W395.

8 years ago
Uhmmm... Help? I tried to GRANT ALL PRIVILEGES ON USERS_TBL TO PUBLIC before running the JUnit tests but still not luck...
Hi Jeanne

Thanks for the reply! Yes, I also run as user "sa"
Hi Ranchers!

I'm currently facing a problem when running a JUnit test within an ANT script. My Unit test calls for an HSQLDB query. Outside of this JUnit test, all my queries like creating a table, insert data to the table and selecting data from the table runs fine. However, when time comes to call my test case class, it throws out a nested exception is java.sql.SQLException: user lacks privilege or object not found: USERS_TBL

I'm running an in-memory database

Below is the stack trace:

[junit] StatementCallback; bad SQL grammar [SELECT user_seq_id, username, pa
ssword FROM users_tbl]; nested exception is java.sql.SQLException: user lacks pr
ivilege or object not found: USERS_TBL
[junit] org.springframework.jdbc.BadSqlGrammarException: StatementCallback;
bad SQL grammar [SELECT user_seq_id, username, password FROM users_tbl]; nested
exception is java.sql.SQLException: user lacks privilege or object not found: US
[junit] at org.springframework.jdbc.support.SQLStateSQLExceptionTranslat
[junit] at org.springframework.jdbc.support.AbstractFallbackSQLException
[junit] at org.springframework.jdbc.support.AbstractFallbackSQLException
[junit] at org.springframework.jdbc.support.AbstractFallbackSQLException
[junit] at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTempla
[junit] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate
[junit] at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate
[junit] at com.mycompany.dao.spring.UserDAOSpringImpl.findUsers(UserDAO

Below is the Spring JDBC code

Thank you very much and I look forward to your kind answers.
Although... I think there are 3rd party initiatives to allow writing in the Java language then the compiler converts to Objective C code. I don't know if anyone's doing this for commercial purpose right now.
9 years ago
Hi guys!

I need to know how to configure Velocity properly. I'm using velocity in a batch(CLI) process to send an e-mail and my template file located in a directory somewhere in the file system. I'm using Eclipse and I made sure that the location of my template is included in the classpath (if it is ever needed to do so).

Assuming that my .vm (template) file is located in C:/opt/templates/

I initialize Velocity like this

And load my template like the following

A call to getTemplate throws the error below:

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'my_template.vm'

Is anyone familiar with this? Thanks!