In Javascript we can define an object like this
let obj={
property1:67,
func1: function (){
//Some code
}
}
Now if we want add a new property to obj
I can just add a new property like this
obj.property2=733; //some value or function
Now I want to do the same thing in Java also.
I have a class Test
public class Test{
int property1=67;
public void func1(){
//Some code
}
}
Now is it possible to do like the same thing like statement #2 in Java also?
Edit: From the answers I got to know that we can use a Map for properties. Now I want to know for methods. Thanks