AmitDiwan has Published 10744 Articles

What are C++ features missing in Java?

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 09:20:06

1K+ Views

There are many features that can be seen in C++ but not in Java. A few of them have been listed below −No unsigned int option in JavaNo destructor in Java as well as ‘delete’ since garbage collector performs this operation for it.No friend classes or friend functions in Java.There ... Read More

Examples of soft references and phantom references?

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 09:17:59

281 Views

Soft references are often used to implement memory-sensitive caches. Let us see an example of soft references in Java −Example Live Demoimport java.lang.ref.SoftReference; class Demo{    public void display_msg(){       System.out.println("Hello there");    } } public class Demo_example{    public static void main(String[] args){       Demo ... Read More

Unreachable statement using the non-final variable in Java

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 09:06:35

130 Views

Following is an example, wherein we will see unreachable statement using the non-final variable −Exampleclass Demo_example {    int a = 2, b = 3;    void display_msg(){       while (a < b){          System.out.println("The first variable is greater than the second");       ... Read More

Unreachable statement using final variable in Java

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 09:04:48

200 Views

Unreachable statements are those that don’t get executed when the code is being executed. This could be so because −There is a return statement before the code.There is an infinite loop in the code.The execution of the code is terminated forcibly before it executes.Here, we will see how the unreachable ... Read More

Types of References in Java

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 09:02:34

837 Views

There are four different kinds of references based on the way in which the data is garbage collected.Strong referencesWeak referencesSoft referencesPhantom referencesStrong referenceIt is the default type of reference object. An object that has active strong reference can’t be garbage collected. It is possible only if the variable that is ... Read More

Type Erasure in Java

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 08:59:55

170 Views

To support generic programming, as well as perform a stricter type check, Java implements type erasure.All type parameters in generic types are replaced with the bound (if unbounded) or object type. This way, the bytecode will only contain classes, methods, and interfaces.Type casts to preserve the type.Bridge methods are generated ... Read More

Shuffle or Randomize a list in Java

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 08:56:23

297 Views

To shuffle a list in Java, the code is as follows −Example Live Demoimport java.util.*; public class Demo{    public static void main(String[] args){       ArrayList my_list = new ArrayList();       my_list.add("Hello");       my_list.add(", ");       my_list.add("this");       my_list.add("is");     ... Read More

What is the maximum possible value of an integer in Java ?

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 08:50:41

3K+ Views

The MAX_VALUE is used to find the maximum possible value for an integer in Java. Let us see an example −Example Live Demopublic class Demo{    public static void main(String[] args){       System.out.println("The type is");       System.out.println(Integer.TYPE);       System.out.println("The size is");       System.out.println(Integer.SIZE); ... Read More

Java Program for Longest Palindromic Subsequence

AmitDiwan

AmitDiwan

Updated on 17-Aug-2020 08:42:15

238 Views

For longest Palindromic subsequence, the Java code is as follows −Example Live Demopublic class Demo{    static String longest_seq(String str_1, String str_2){       int str_1_len = str_1.length();       int str_2_len = str_2.length();       char str_1_arr[] = str_1.toCharArray();       char str_2_arr[] = str_2.toCharArray();   ... Read More

How to add properties and methods to an existing object in JavaScript?

AmitDiwan

AmitDiwan

Updated on 22-Jul-2020 08:04:08

256 Views

Following is the code for adding properties and methods to an existing object in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: ... Read More

Advertisements