What is the difference between public, protected, package-private and private in Java?

In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), public, protected and private, while making class and interface and dealing with inheritance?

What is the difference between covariance and contra-variance in programming languages?

Can anyone explain the concept of covariance and contravariance in programming language theory?

Difference between FetchType LAZY and EAGER in Java Persistence API?

I am a newbie to Java Persistence API and Hibernate. What is the difference between FetchType.LAZY and FetchType.EAGER in Java Persistence API?

Saving to properties file escapes :

Does anyone know why the colons are getting escaped when I store the properties file? I'm doing this: Properties prop = new Properties(); // Set the properties...

GSON - Date format

I'm trying to have a custom date format in Gson output, but .setDateFormat(DateFormat.FULL) doesn't seem to work and it the same with .registerTypeAdapter(Date.class, new DateSerializer()). It's...

Empty file after upload with JAVA on my ftp server

I am facing some problem while trying to upload a file on my ftp server with java. here is my code function : public static void upload_files(String un, String pw, String ip, String f){ try ...

java paging util

I have List of Object. I need to do pagination. The input parameters are the maximum number object per Page and Page number. For example input list = ("a", "b", "c", "d", "e", "f") The maximum...

javax.servlet.UnavailableException after an upgrade to WAS 7

I have migrated my application from WAS 6 to WAS 7. The code is not showing any compilation error or missing anything, but when I am trying to run the application, I get following exception. ...

JDBC Derby driver not found

I've followed the JDBC tutorial at: http://docs.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html, and managed to build and create my own JDBC database without too much fuss. However now...

Could I use Java servlet Filter class from other referenced class library?

I have five web applications in my project and want to filter HTTP requests, but I don't want to write a Filter class for each web application because there will be no application specific...

Java 8 Supplier & Consumer explanation for the layperson

As a non-Java programmer learning Java, I am reading about Supplier and Consumer interfaces at the moment. And I can't wrap my head around their usage and meaning. When and why you would use these...

Java 8 lambda Void argument

Let's say I have the following functional interface in Java 8: interface Action<T, U> { U execute(T t); } And for some cases I need an action without arguments or return type. So I...

Use JDBC/Mysql Connector in intellij idea

I'm new in Java, and I need to establish a connection to a MySQL server (local), I have add the libraries in Intellij idea but it seems not work, the IDE can't find the class i think... I become...

How do I load a texture in LWJGL from a PNG without Slick?

I'm wondering how I would render a cube with a different PNG Texture on each side, and I'd like to stay away from other Third-Party Libraries other than LWJGL.

PCM to WAV conversion in android

I have recorded a sound using AudioRecord class . But its not playable via music player. So I have added some header information to the audio file. Though its now playable via music player but its...

Derby db connectivity problems

I receive the following error msg when attempting to connect to a derby network server: java.sql.SQLException: No suitable driver found for jdbc:derby://localhost/studentdb;create=true Derby is...

DocumentFile is very slow

I want to create something like "PDF Viewer app". Application will search for all *.pdf files in location chosen by user. User can choose this folder by this function: Intent intent = new...

How do you keep track of a board game positions live? (Java)

I am creating a board game in java using a 2d array. The board is shown in a JFrame. How do you "move" pieces on the 2d array and display them live on the screen (the 2d array is shown with...

How does abstraction help in hiding the implementation details in Java?

Abstraction is a process of hiding the implementation details and showing only functionality to the user. Another way, it shows only important things to the user and hides the internal details....

What is the difference between intermediate and terminal operations?

can someone tell me What is the difference between intermediate and terminal operations for Stream? Stream operations are combined into pipelines to process streams. All operations are either...

JAVA - Converstion String (With dot) to Long

I have problem about convertion from string to long value. Example : String a = "4.0"; Long l= Long.parseLong(a); When I execute, get exception: Exception in thread "main"...

Why am I getting an IllegalStateException when stopping MediaRecorder?

To get a better understanding of audio recording and playback in Android, I've implemented a clone of the code in the android dev tutorial...

How to set JDK 8 for Jenkins and JDK 14 for build job?

I am use Jenkins 2.222.4 on Windows 2016 server. How to set JDK 8 for Jenkins and JDK 14 for build job? Thank you! Because I really need this type of configuration. C:\Users\Administrator>java...

In Selenium Java client what is the difference between addArguments and setPreference methods?

When using Java and Selenium, frequently when I google how to change a certain behaviour I find some example that explains how to change a setting using either addArgument or set_preferences,...

How to run a main method method without building the WHOLE maven project in idea?

I have a maven project with many demo classes with their own main methods, they don't dependent on each other. I used to be able to run a class by right clicking on its main method, and select Run...

Design Tab is Blank in Eclipse IDE

I recently bought Macbook with an M1 processor for programming. I have installed Eclipse IDE for JAVA Programming. After Installing Window BUilder and the required Softwares from Eclipse Market...

Why is my LWJGL alpha_anti_aliasing not working?

I just wrote some code with LWJGL and when I start my program now, it just outputs a square with rounded edges (The round edges are created in a shader, not by a texture). This square has a lot of...

android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify

After upgrading to android 12, the application is not compiling. It shows "Manifest merger failed with multiple errors, see logs" Error showing in Merged manifest: Merging Errors: Error:...

How to setup NetBeans IDE for Python Development

I was using PyDev plugin in eclipse for developing python. But now I switched to NetBeans IDE 12.6 and I searched google for finding python plugins for NetBeans. I found a plugin called...

What are some possible reasons for "Zip Path Traversal Vulnerability" happens only in Android 11?

Based on https://support.google.com/faqs/answer/9294009, we implement "Zip Path Traversal Vulnerability" detection in our code. We are getting crash log from Google Play Console, as we run throw...