Category "java"

Java initialize array with mutiple type parameters error java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to

public class ArrayPQK<P extends Comparable<P>, T> implements PQK<P, T> { int maxsize; int size; int head,tail; Pair<P, T>[] nodes; publi

How do I compare strings in Java?

I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals()

Getting 'com.android.tools.r8.internal.Hc: Sealed classes are not supported as program classes' when trying to load Microsoft SQL Server JDBC

I'm using android studio to connect to a Microsoft SQL Server and I can't use the JDBC for JDK 17. It just appears with the following error message: 'com.androi

Default algo for RandomGenerator (L32X64MixRandom) generates the same number each time

The default algo for RandomGenerator ie. L32X64MixRandom as of JDK 18 (available since 17), generates the same number each time on individual invocations. jshel

Invalid Class name driver JDBC SQLite

I have this error "Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for /Users/testdb.db" when trying to select q

Java Mybatis to Python SQL Alchemy - is there resultMap mybatis equivalent in SQLAlchemy python. which logically maps join queries removing duplicates

Say we have a select query like select a.col1,a.col2,a.col3,b.col1,b,col2,c.col1 from a, b, c where a.col1(+)=b.col2 and b.col3(+)=c.col2 In mybatis xml we hav

How to load all classes from the byte array of a JAR file at runtime?

I have an array of bytes of a JAR file and I need to load all the classes from this array. How can I do this without converting this array to a file?

How can I make a JMenuItem open a JTextField when I click it?

I am writing code that lets the user enter, search for and remove participants. Right now I have the JFrame that has a JMenu on it with a few JMenuItems. When I

Interface and Implementations with Separate Templates

I have a Java interface with several implementing classes. Each implementation class needs its own associated (sub)template. At runtime I add a collection (Li

Intent from widget not taken into account since Android SDK 31

My app offers the possibility to launch it through as many widgets as wanted by the user. To determine which widget trigerred the launch, I use an extra paramet

How to avoid "ConcurrentModificationException" while add ArrayList elements?

I'm trying to add an item to the ArrayList in a certain order Iterator<Rating> it = arr.iterator(); while(it.hasNext()){ Rating o = it.next(); int

(Java) How to map one column of a CSV file to another column of a different type?

So for this problem, my function is supposed to return the top-10 list of avengers with the most appearances (in decreasing order). In the Avenger class it is

How to check if double is NEGATIVE_INFINITY in Java

How do I check if double is NEGATIVE_INFINITY and not POSITIVE_INFINITY? There is only one method in Double class isInfinite() which checks whether the double i

How can I make executable file from jar with embedded JVM?

For example, I have someFile.jar. I can run it simply using java -jar someFile.jar. But I want to create some files (for example .deb file) to install this jar

Spring MVC with HATEOAS

I use Spring MVC (no Spring Boot) with HATEOAS in order to get HAL-FORMS with Affordance response like this: "_links": { "index": { "hre

onPurchasesUpdated called multiple times

I have set up in-app billing on an Android app (java). When I call launchBillingFlow on the BillingClient: BillingFlowParams billingFlowParams = Billing

Calling a method from one class to another to get its value

package Multiplemethods; import java.util.stream.DoubleStream; public class TimeOffice { public static void main(String args[]){ //instance variables dou

Add toolbar and drawer menu to Android Google Maps Activity

I have created a standard Google Maps Activity in my app in Android Studio and the map works as expected. My Activity is called 'NativeMap' and then the activit

Android API 28 getBitmap throwing "no such column" error

On Android API 28, I'm trying to get the album art for a particular album using the albumID. The code throws the following error on getBitmap android.database.s

How to mock bean with @PostConstruct method

I need to mock some class that contains @PostConstruct method, but I get NullPointerException inside @PostConstruct method. My code looks like the following: @S