Despite specifying JDK 1.7 in all project settings (including in File -> Project Structure -> Project :: Project SDK), the following error is produced by IntelliJ 13 when trying to compile some simple Java 7 code which does use the diamond operator: Is there any other place in the configuration where th…
Tag: java
Abstract class extends concrete class
I earlier learned that abstract class can extend concrete class. Though I don’t see the reason for it from JAVA designers, but it is ok. I also learned that abstract class that extends concrete class can make overriden methods abstract. Why? Can you provide with use case where it is useful? I am trying …
Apache POI – setting left/right print margin in Excel
Is that possible – with apache POI – to set left or right print margin for Excel sheet? The default margins are quite big. I cannot see neither setLeftMargin nor setRightMargin in XSSFPrintSetup, but only header and footer: Is there any kind friend that could help me a little? Answer The sheet mar…
best ways to dynamically load config in java?
i am designing a web service in java where i need to do a sort of AB testing with requests in java. Basically I’m looking for ways to easily configure parameters which will be dynamically loaded by a request handler to determine the code path based on config values. for example, let’s say i need t…
Calculate average of a huge long array
I’m trying to calculate the average of many (more than 200) long (primitive type) values stored in an array. Usually you add all the numbers and divide it by the number of the values. But this is not possible in this case since there is no primitive datatype in Java capable of holding such a large numbe…
Signing a jnlp in order to get rid of the Security Warning
I am developing at a company where a jnlp file is used to start a swing web based java application. It has plenty of jars that are downloaded to the client’s jvm cache. When I updated my jvm to its currently latest version (build 1.7.0_45-b18) I started seeing the security warning below when I try to ru…
Map Reduce flow in Hadoop
I’m learning Hadoop using the book Hadoop in Practice, and while reading chapter 1 i came across this diagram: From the Hadoop docs:(http://hadoop.apache.org/docs/current2/api/org/apache/hadoop/mapred/Reducer.html) 1.Shuffle Reducer is input the grouped output of a Mapper. In the phase the framework, fo…
Disable Column Header sorting on a JTable
Is it possible to disable manual sorting on a JTable after adding a sorter? So I have a JTable that has the following sorter attached to it (basically sorts by column 3 when the table is initialised): This works fine, however the user is still able to click on the column headers in the table and sort by any o…
Can someone help me with this knight’s tour code?
The code seems fine to me, but the output is too short and the answer is no when it should be yes (starting at a,0, the knight should be able to tour the entire board) By the way, the reason my positionsVisted array is [9][9] is because I wanted the values to be 1-8, to match the output. This is
Setting all values in a boolean array to true
Is there a method in Java for setting all values in a boolean array to true? Obviously I could do this with a for loop, but if I have (for example) a large 3D array, I imagine using a loop would be quite inefficient. Is there any method in Java to set all values in a certain array to true,