What does Java option -Xmx stand for?

-XmxnSpecify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 … Read more

Java Using Nodes with LinkedList

You don’t actually need a separate LinkedList class; the ListNode class is a linked list. Or, to state it differently, a reference to the head of the list is a reference to the list. The use of head, tail, current, prev in the sample code you posted has come from a double-linked list which is a data … Read more

How do I use a PriorityQueue?

Use the constructor overload which takes a Comparator<? super E> comparator and pass in a comparator which compares in the appropriate way for your sort order. If you give an example of how you want to sort, we can provide some sample code to implement the comparator if you’re not sure. (It’s pretty straightforward though.) As has … Read more

Working with a List of Lists in Java

I’m trying to read a CSV file into a list of lists (of strings), pass it around for getting some data from a database, build a new list of lists of new data, then pass that list of lists so it can be written to a new CSV file. I’ve looked all over, and I can’t … Read more

com.atomikos.icatch.SysException: Error in init: Log already in use? tmlog in ./

I have a very big problem with my atomikos. I cant create bean because of below error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘authenticatingSignInAdapter’: Unsatisfied dependency expressed through field ‘userRepoAutowired’: Error creating bean with name ‘userRepo’: Invocation of init method failed; nested exception is com.atomikos.icatch.SysException: Error in init: Log already in use? tmlog in ./; … Read more

Understanding Spring @Autowired usage

TL;DR The @Autowired annotation spares you the need to do the wiring by yourself in the XML file (or any other way) and just finds for you what needs to be injected where and does that for you. Full explanation The @Autowired annotation allows you to skip configurations elsewhere of what to inject and just does it for you. … Read more

Round a double to 2 decimal places

Here’s an utility that rounds (instead of truncating) a double to specified number of decimal places. For example: Original version; watch out with this This breaks down badly in corner cases with either a very high number of decimal places (e.g. round(1000.0d, 17)) or large integer part (e.g. round(90080070060.1d, 9)). Thanks to Sloin for pointing this out. I’ve been using the above to round … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)