If I write something like this


Which type has the ’19’? Is it int or byte? Or doesn’t it have a type yet?
This 19 is known as an integer literal. There are all sorts of literals, floating point, String, character, etc.

What is integer literal
Integer data types consist of the following primitive data types: int,long, byte, and short.byte, int, long, and short can be expressed in decimal(base
10), hexadecimal(base 16) or octal(base 8) number systems as well.
Prefix 0 is used to indicate octal and prefix 0x indicates hexadecimal when using these number systems for literals.


int decimal = 100;
int octal = 0144;
int hexa =  0x64;

Literal means any number,Text or Other information that represents a value.

Different Values that can be assigned to Integer Variable (Integer data type Literal) are

  1. Decimal Literals
  2. Octal Literals
  3. Hexadecimal Literals
  4. Binary Literals
  5. Long Literals
  6. Values with Underscore in Between

In java String Builder Should be Used in case you need to perform concatenate more string together.


 public String toString()
    return  a + b + c ;

For the above code using + will be converted to

a = new StringBuilder()

For the above case you can use concat as below but since + will be converted as String Builder its better to use + rather than concat.

 public String toString()
    return  a.concat(b).concat(c);

The key is whether you are writing a single concatenation all in one place or accumulating it over time.

There's no point in explicitly using StringBuilder.

But if you are building a string e.g. inside a loop, use StringBuilder.

To clarify, assuming that hugeArray contains thousands of strings, code like this:

String result = "";
for (String s : hugeArray) {
    result = result + s;

It should be as below

StringBuilder sb = new StringBuilder();

for (String s : hugeArray) {
String result = sb.toString();