Posts
Showing posts from January, 2022
#java #class #immutable How to create an Immutable class ?
- Get link
- X
- Other Apps
How to create an Immutable class ?
- Get link
- X
- Other Apps
What is an immutable class in Java? Immutable objects are instances whose state doesn’t change after it has been initialized. There are many immutable classes like String, Boolean, Byte, Short, Integer, Long, Float, Double etc. In short, all the wrapper classes and String classes are immutable. We can also create our own immutable class by creating a final class that has final data members. How to create an Immutable class ? Rules for creating Immutable class in Java− Make class final − class should be final so that it cannot be extended. Make each field final & private − Each field should be final so that they cannot be modified after initialization. Create a getter method for each field. − Create a public getter method for each field. fields should be private. No setter method for each field. − Do not create a public setter method for any of the fields. Create a constructor − Such a constructor will be used to initialize properties once. Please refer video: How to create an Immu...
#string #java #stringbuffer #immutable #mutable How to Reverse a String ...
- Get link
- X
- Other Apps
#java #faq #jarray #multidimensionalarray Jagged Array in Java
- Get link
- X
- Other Apps
#parameter #pathparameter #queryparameter API TERMINOLOGY : Part-2
- Get link
- X
- Other Apps
Why java is Platform Independent?
- Get link
- X
- Other Apps
How is Java platform independent? Platform means → H/W+S/W+OS(Windows, Mac, Linux etc.) Java is a platform-independent language. In other words, once you write your code then run it anywhere, on any platform that provides the environment to run it. This environment is the Java Virtual Machine (JVM). The JVM should be present to execute the code. The JVM is different for each platform. In the case of Java, platform independence does not mean that you can run the code anywhere, you can run it wherever the environment is provided. To run a program on any machine you need to convert it to the machine language so that the specific machine can understand it. In Java the source code is not directly converted into the machine code. It is first converted into the byte code by the compiler. In Java, the byte code is interpreted by the JVM and converts it into the machine specific code. So the Java Vir...