Varargs in Java
A variable arity parameter lets a method accept any number of arguments, and inside the method it is simply an array.
Core Java, object oriented programming, collections, multithreading and JDBC.
100 notes in 18 topics
A variable arity parameter lets a method accept any number of arguments, and inside the method it is simply an array.
Java always passes arguments by value. For objects the value copied is the reference, which explains every result that looks like pass by reference.
An array is a fixed size object holding elements of one type, indexed from zero, with the length fixed at creation.
Java has no true two dimensional array. It has arrays of arrays, which is what makes jagged shapes possible.
String is an immutable object with a shared literal pool, and both facts explain how comparison, concatenation and performance behave.
When text is built piece by piece, a mutable buffer avoids the copying that repeated String concatenation forces.
A class describes the state and behaviour of a kind of thing, and an object is one concrete instance of that description held in memory.
A constructor runs once when an object is created, and its job is to leave that object in a valid state.
Inside an instance method, this is a reference to the object the method was called on, which resolves shadowing and enables chaining.
static binds a member to the class rather than to any instance, which changes when it is created, how it is accessed and what it can see.
Encapsulation hides internal state behind a deliberate public surface, so a class can guarantee its own rules stay true.
Four levels of visibility control who can see a member, and choosing the narrowest one that works is the single easiest design win.