Category "java"

How to convert a arraylist <String> to arrayList <Integer> and Calculate the values of Integers on it?

How i am supposed to calculate ArrayList String from Listview values into ArrayList Integer and back to Listview, Because i've been making a application for And

How to convert String having key=value pairs to Json

myString = {AcquirerName=abc, AcquiringBankCode=0.2, ApprovalCode=00}; I want to convert it to the following string. {"AcquirerName": "abc", "AcquiringBankCode

What is a NullPointerException, and how do I fix it?

What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them? What methods/tools can be used to determine the cause

MockMVC - Service method does not appeared to be called, works in postman, responding with null for test

I am trying to test the controller for creating a new league method, but it just returns null, and when I put a system.out.println in the service impl method, i

Java Maven - CVE-2017-1000487 on plexus-utils-2.0.4.jar plexus-utils-3.0.10.jar

Small question regarding Java and maven please. With a very simple project, reproducible 100%, with just this code snippet (please feel free to copy paste) <

What does a generic type before the type name in a constructor call mean?

What does the code mean like this? new <Number>ArrayList() I know the correct way to write it like this new ArrayList<Number>() The first is not a g

Why there is no compilation error when I am using different data types for switch expression and case value in this case

public class Conditionsif { public static void main(String[] args) { // TODO Auto-generated method stub int day=1; switch(day){

Why does the PrintWriter class (and other writers) require a call to flush after writing?

I have noticed that some I/O Classes in Java (and a lot others, like the BufferedWriter and FileWriter), require a call to flush() after writing. (With the exce

Using If in RecyclerView, doesnt show all the item of the list

I am trying create a RecycleView for my chat application and to align the sent and arrived messages to the left and right. I used an if state to check if that i

Custom IdentifierGenerator returns null

So, I want to customize the ID for a "FriendID" with IdentifierGenerator, and I want to make it as simple as possible first just to make sure it works. Been wat

Spring one Controller for nested entities

I'm working on a school project and I'm not sure how to implement this case. I would like to implement it as best practice. Right now I have 3 entities -> St

Is there a way to make a button to loop user inputs for a number of times before terminating?

I have been turning the popular guessing game into an app using Java in Android Studio. I want it so that a user can make up to five trials before the answer is

How to delete table records on cascade without the program freezing?

this is my delete button method, it takes the college name as a primary key and deletes it so the whole record gets deleted. However, it can't be deleted becaus

TableView Not Being Populated [duplicate]

Does anyone have any idea why the table is not getting populated with the products? MainController class: //imports Public class MainControll

How can I spoof prop values that don't belong to android.os.Build?

With the following segment of code I'm able to spoof certain build.prop parameters such as brand, manufactuer, device, product and model: data class DeviceEntri

Get seconds between next day with time

I am trying to get the Duration until the next time, depending on a Day of Week in Java. I want to be able to schedule a Java task for the next day in a list, a

I ned a while loop statment that makes the calculations loop and ask again

im not too sure how you add a loop statement to this. I want it to be a while loop that makes it do that the calculations repeat after finishing. I've tried but

Accessing specific elements in Arraylist of Objects

Really confused on how to access just the age of a specific student where all the information of students have been stored in a textfile. I am reading the textf

/Main.java:17: error: non-static variable this cannot be referenced from a static context ^ 1 error [duplicate]

In this simple code can anyone explain me what's wrong ? public class Main { public class UserValidator { public void validateName(String

In Java how to synchronize cache read and write operations

I am working on implementing a simple cache using ArrayList in my application. I would like to synchronize cache update operations, while updating the cache I s