What does Scanner input = new Scanner(System.in) actually mean?

Alright, let’s elaborate with some simplified explanation about the Scanner class. It is a standard Oracle class which you can use by calling the import java.util.Scanner. So let’s make a basic example of the class: Now when you call Scanner input = new Scanner(System.in); you make a new object of the Scanner class (so you make a new “Scanner”) and you store … Read more

What is the default initialization of an array in Java?

Everything in a Java program not explicitly set to something by the programmer, is initialized to a zero value. For references (anything that holds an object) that is null. For int/short/byte/long that is a 0. For float/double that is a 0.0 For booleans that is a false. For char that is the null character ‘\u0000’ (whose decimal equivalent is 0). When … Read more

Difference between a HashMap and a dictionary ADT

In terms of Java, both the class HashMap and the class Dictionary are implementations of the “Map” abstract data type. Abstract data types are not specific to any one programming language, and the Map ADT can also be known as a Hash, or a Dictionary, or an Associative Array (others at http://en.wikipedia.org/wiki/Associative_array). (Notice we’re making a distinction between the Dictionary class and the Dictionary … Read more

Static Block in Java

It’s a static initializer. It’s executed when the class is loaded (or initialized, to be precise, but you usually don’t notice the difference). It can be thought of as a “class constructor”. Note that there are also instance initializers, which look the same, except that they don’t have the static keyword. Those are run in addition to the code in the constructor … Read more

Cannot resolve symbol “Intent”

Try the following Rebuilding the project Cleaning the project Syncing with Gradle Files Closing the Project, closing AS and relaunching / reopening File > Invalidate Caches / Restart Double checking all support libraries are up to date in the SDK manager Exit Android Studio Back up your project Delete all the .iml files and the … Read more

How can I convert a .jar to an .exe?

Launch4j works on both Windows and Linux/Mac. But if you’re running Linux/Mac, there is a way to embed your jar into a shell script that performs the autolaunch for you, so you have only one runnable file: exestub.sh: Then you create your runnable file from your jar: It works the same way launch4j works: because a … Read more

Java comparing generic types

You cannot overload operators in Java. The < operator only applies to primitive (or numeric) types, not reference types. Since T is a type variable that represents a reference type, you cannot use < on variables of type T. You have to use check the value returned and decide to do what you wish with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)