Latest Questions

Get Answers to Your Coding Questions

53
Votes
Published 02 Sep, 2022
Java - Increment a Integer's int value?

How do I increment a Integer's value in Java? I know I can get the value with intValue, and I can set it with new Integer(int i). playerID.intValue()++; does not seem to work. Note: PlayerID is a...

75
Votes
Published 17 Sep, 2022
Java - Country, state and city spinner not working correctly

I've been working on a registration form app with few spinner widgets being used in it. The spinners are to be used to select Country, State and City. Hence, these spinners need to be interconnected s...

222
Votes
Published 25 Aug, 2022
Java - Is there a way to dump a stack trace without throwing an exception in java?

I am thinking of creating a debug tool for my Java application. I am wondering if it is possible to get a stack trace, just like Exception.printStackTrace() but without actually throwing an exception...

97
Votes
Published 10 Sep, 2022
Java - Transparent background in ImageButton with ripple effect?

I want to programmatically remove the grey background in ImageButton. I tried many method of removing it like - imageButton.setBackgroundDrawable(null); but on implementing them, I don't get the ri...

49
Votes
Published 26 Aug, 2022
Java - Complex object (de)serialization into JSON using GSON

I have a problem with serializing and deserializing my object structure with GSON. In order to describe the problem i'll have to describe my class structure a bit: I have a java abstract class, let's...

54
Votes
Published 04 Sep, 2022
Java - @Conditional on bean initialization

I have been searching for this for a while. Till now, I found this blog very useful but did not solve my problem. I want to @Autowired a bean only if a flag is true, else I want that to be null Use...

71
Votes
Published 29 Aug, 2022
Java - What's the advantage of making an inner class as static with Java?

I have an inner class in my Java class. When I run find bugs, it recommends(warns) to make it as static. What's the point of this warning? What's the advantage of making a inner class as static...

128
Votes
Published 16 Sep, 2022
Java - Why shouldn't I use immutable POJOs instead of JavaBeans?

I have implemented a few Java applications now, only desktop applications so far. I prefer to use immutable objects for passing the data around in the application instead of using objects with mutator...

82
Votes
Published 25 Aug, 2022
Java - How to split a Wav file into channels in java?

I would like to write a Java program to split a wav file into channels. The input would be a wav file, and the output would be as many wav files as there are channels. I can read a wav file in Java bu...

47
Votes
Published 23 Aug, 2022
Java - No JSF support in IntelliJ IDEA 14.1.4

The facts: IntelliJ IDEA 14.1.4 Ultimate (Educational Use) Java EAR with Web Module Wildfly Application Server Primefaces 5.0 I just can't find any support for JSF in my IntelliJ IDE. There is no...

79
Votes
Published 17 Sep, 2022
Java - Embedded MongoDB with Spring not working

I am trying to create a Spring application with WebFlux and an embedded MongoDB. However, even if my tests runs perfectly, I can't start my application because it seems that embedded mongodb has not s...

40
Votes
Published 28 Aug, 2022
Java - Using JavaFX Application.stop() method over Shutdownhook

So im using shutdownhook to clean up, bud since its not always guaranteed that shutdownhooks thread executes , should i just push this code onto JavaFX Application Thread (method stop()) which execute...

50
Votes
Published 10 Sep, 2022
Java - How to iterate hashmap in reverse order in Java

I am trying this for some hour but not finding any best approach to achieve iteration of hashmap in reverse order, this is the hashmap I have. Map<Integer, List<String>> map = new H...

33
Votes
Published 02 Sep, 2022
Java - IntelliJ cannot resolve any symbols or methods

IntelliJ IDEA 2017.2 I know this has been asked, but I have tried every fix I could find, as shown below. Every symbol in my java code has an error Cannot resolve method, or Cannot resolve symbol....

276
Votes
Published 26 Aug, 2022
Java - Override back button to act like home button

On pressing the back button, I'd like my application to go into the stopped state, rather than the destroyed state. In the Android docs it states: ...not all activities have the behavior that the...

30
Votes
Published 21 Aug, 2022
Java - How to iterate through a String

How can I iterate through a string in Java? I'm trying to use a foreach style for loop for (char x : examplestring) { //action }

83
Votes
Published 29 Aug, 2022
Java - Date.getTime() not including time?

Can't understand why the following takes place: String date = "06-04-2007 07:05"; SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm"); Date myDate = fmt.parse(date); System.out.println(...

23
Votes
Published 07 Sep, 2022
Java - IP camera with OpenCv in Java

I am trying to get and display an video stream from a IP camera. I found some sample code here:http://answers.opencv.org/question/24012/reading-video-stream-from-ip-camera-in-opencv-java/ But it is n...

69
Votes
Published 03 Sep, 2022
Java - Active threads in ExecutorService

Any ideas how to determine the number of active threads currently running in an ExecutorService?

50
Votes
Published 12 Sep, 2022
Java - Setting ASCII mode in Jsch

I need to overcome a Unix - Windows file format (LF to CRLF) issue I'm currently having. The ftp client I am using is Jsch from Jcraft. The documentation online is very bare, although I have come acr...

33
Votes
Published 15 Sep, 2022
Java - What size of initialization vector needed for AES-256 encryption in java?

I am using AES-256 encryption with CFB mode. I have to use 32 byte key. But I am little bit confused about the initialization vector. How many bytes of initialization vector should be used with AES-2...

42
Votes
Published 08 Sep, 2022
Java - How to get Named Entity Extraction using GATE Annie in Java?

I am newbie in GATE ANNIE. I tried GATE GUI interface and got experience to do task on it. I wanted to know how can I implement Named Entity Extraction in Java? I did R&D but unable to find any...

52
Votes
Published 29 Aug, 2022
Java - Difference between getClass().getClassLoader().getResource() and getClass.getResource()?

What is the difference between getClass().getClassLoader().getResource() and getClass.getResource()? When retrieving files from resources, which one should I use in what circumstances?

32
Votes
Published 05 Sep, 2022
Java - Hibernate UUID as UUID type

Trying to use a UUID as my id for PostgreSQL and H2, the current exceptions are for H2 java.lang.IllegalArgumentException: Can not set java.util.UUID field com.lm.model.Task.id to java.lang.String at...

57
Votes
Published 25 Aug, 2022
Java - How to use Timer class to call a method, do something, reset timer, repeat?

I'm a Java beginner and have been futzing around with various solutions to this problem and have gotten myself kind of knotted up. I've tried with Threads and then discovered this Timer class and have...

91
Votes
Published 13 Sep, 2022
Java - Maven error "Unable to initialize main class" when I try to run a jar file I just created

I created a .jar file using Maven in the command line. It created the .jar file. When I tried to run it in the command line I got this error: java -jar target\github-automation-1.0.0.jar Error: Unabl...

48
Votes
Published 29 Aug, 2022
Java - How can I save a file to the class path

How can I save / load a file that is located where my classes are? I don't the physical path to that location before and I want dynamically to find that file. I want to load an XML file and write an...

108
Votes
Published 24 Aug, 2022
Java - What is the difference between Caching and Pooling?

What is the difference between Caching and Pooling?

42
Votes
Published 17 Sep, 2022
Java - TestDome: my solution works but I am only getting %50 right and not %100?

This is the scenario question: A frog only moves forward, but it can move in steps 1 inch long or in jumps 2 inches long. A frog can cover the same distance using different combinations of steps and...

214
Votes
Published 28 Aug, 2022
Java - How would you implement an LRU cache in Java?

Please don't say EHCache or OSCache, etc. Assume for purposes of this question that I want to implement my own using just the SDK (learning by doing). Given that the cache will be used in a multithrea...