Monday , June 21 2021
Home / Java / JAVA #27 Object Type in Java

JAVA #27 Object Type in Java

Object Type in Java

  • An object is a class instance or an array.
  • The reference values (often just references) are pointers to these objects, and a special null reference, which refers to no object.
  • A class instance is explicitly created by a class instance creation expression .
  • An array is explicitly created by an array creation expression.
  • A new class instance is implicitly created when the string concatenation operator + is used in a non-constant expression, resulting in a new object of type String .
  • A new array object is implicitly created when an array initializer expression is evaluated; this can occur when a class or interface is initialized , when a new instance of a class is created , or when a local variable declaration statement is executed .
  • New objects of the types Boolean, Byte, Short, Character, Integer, Long, Float, and Double may be implicitly created by boxing conversion .

 

// File name ObjectDataType.java
package objectdatatype;
public class ObjectDataType {
    public static void main(String[] args) {
        classValue objVal = new classValue();
        
        objVal.write(new Float(23.24));
        
        System.out.println(objVal.read());
    }
    
}

class classValue
{
    private Object storeValue;
    
    public void write(Object val) // Setter Function
    {
        storeValue = val;
    }
    
    public Object read() // Getter Function
    {
        return storeValue;
    }
    
}

 

About Faheem

An adaptable and responsible Software Engineer, who enjoys working with computers and the opportunity to learn new skills and work with new technologies is particularly attractive to me.

Check Also

JAVA #32 – Java application using SQL server (Part: 01)

  In this part we made the GUI front end of a Application.

Leave a Reply

Your email address will not be published.