I have this C# code:
var invoice = new {
code = "01",
otherThings = "etc",
...
}
What would be the equivalent of this in Java?
I tried creating a: Object[] invoice = new Object[]{}
but don't know how to fill the object.
I hope I was clear enough, thanks.
You can write it like that:
Invoice i = new Invoice(){...};
But thats not Clean Code.
just write a constructor with all properties like:
public invoice(String code, String otherThings)
{
this.code = code;
this.otherThings = otherThings;
}
...
Invoice i = new Invoice("asdfasdf", "asdfasdf");
Oject[] invoice = new Object[5];
invoice[0] = (Object)i;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.