-5

I wrote a code using two type of Object styles. Both are working properly. I just want to know what is the difference between these both types.

PatientsTabData ob[] = {new PatientsTabData().SetPatientId(
                Integer.parseInt(String.valueOf(jsonObject.get("PatientId"))))
.SetRxId(Integer.parseInt(String.valueOf(jsonObject.get("TrackingNumber"))))};

PatientsTabData[] ob = {new PatientsTabData().SetPatientId(
                Integer.parseInt(String.valueOf(jsonObject.get("PatientId"))))
.SetRxId(Integer.parseInt(String.valueOf(jsonObject.get("TrackingNumber"))))};

Both types are working.

SanjX
  • 957
  • 1
  • 8
  • 12
  • 3
    None, zero, nada, ninguna. – x80486 Oct 03 '19 at 13:27
  • 3
    The `Object obj[]` declaration was added to make a switch from C to Java simpler. Functionally there is no difference. –  Oct 03 '19 at 13:29
  • Object[] objA, objB; // Both objA and objB are arrays of type object | | | | Object objC[], objD; // WARNING: objC is an array, but objD is just a regular Object – Dushyant Tankariya Oct 03 '19 at 13:29
  • When the same questions have -4 and 223 vote's. If someone can tell me what is the difference between the duplicated question ? –  Oct 03 '19 at 13:30
  • @BorisBorovski It's a duplicate question, which are generally downvoted. –  Oct 03 '19 at 13:39
  • 1
    @Boris Borosvski The other question was also asked _11 years_ ago, which will generate upvotes over a long period of time, and is where all the duplicates are directed. Also the questions that were accepted were different back then as there were not nearly as many answers as there are now. – Nexevis Oct 03 '19 at 13:51
  • @Boris Borovski It Make sens. Thank you. –  Oct 03 '19 at 13:53

2 Answers2

1

The difference might be in convenience and code readability.

https://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html

The local variable declaration statement:

byte[] rowvector, colvector, matrix[];

is equivalent to:

byte rowvector[], colvector[], matrix[][];
jaros
  • 323
  • 1
  • 3
  • 15
0

Java tutorial explains it to be equally functional forms, but the C-like one is not welcome to be used.

lotor
  • 1,060
  • 7
  • 18