Skip to content
Advertisement

zip function for Java

Is there some standard API or established third party library (I am thinking commons or Guava) that provides in Java the equivalent of zip or map vector function in languages like Ruby or Clojure? So the signature (for two collections) would be: where Pair would also be presumably defined in that library. I know its trivial to implement but maybe

Nested if-else behaviour without braces

Consider the following unformatted nested if-else Java code My question is: according to the Java language specifications, to what if does the else branch apply? By hand-reformatting and adding braces, which of these two is correct? Block 1: Block 2: Answer From the Java Language Specification: The Java programming language, like C and C++ and many programming languages before them,

Big O – O(log(n)) code example

Like the Big O notation “O(1)” can describe following code: What code can O(log(n)) describe? Another question: What solutions are there for “Big O problems” (what to do, when getting a lot of data as an input)? Answer Classic example: This will be: 2k = x → Applying log to both sides → k = log(x)

Junit Testing JNDI InitialContext outside the application server

Please help me to mock the above code. Hi Tom Anderson I tried the below code But its giving error as: Please help me to test the code i just want connection from JNDI datasource Answer The orthodox thing to do here would be to change you code so that the Context is injected into it (by a dependency injection

Storing integer as attribute in jsp

I want to pass an Integer value as an attribute in JSP. But when i try an error is returned. Could you tell me a method to store Integer numbers as attributes in JSP? I am getting a casting error saying parseInt() is not suited for handling objects. Answer request.getAttribute returns an Object. you need to cast this to String

EXE4j Jar to exe error

I’m recently Java 7 update 21 JDK and i created java application with netbeans For distributing my jar i use Exe4j 4.5.2 Jar to exe. Now when i used Exe4j it creates exe but when i execute it it shows me error message. “The JVM could not be started. The maximum heap size (-Xmx) might be too large or an

Advertisement