Question: I am now learning Varargs in java.
I wrote this method:

```
 public static void vrati(Object... arguments){
    for(Object i : arguments)

    System.out.println(i);
}

```

Then I called the method:

```
 main.vrati(8,2,"String");

```

So my question is: does varargs cast primitive types to object?
Because I have mixed in int and String in this method call and can access them like is one object.

Answer: 
> 
> So my question does varargs cast primitive types to object?
> 
> 
> 

It casts to the type of the array. If you have

```
a(int... ints)

```

They will be `int`

and if you have

```
b(double... doubles)

```

they will be doubles even if you write `b (1, 2.0f, 10L)`

If you have an

```
c(Object... obj)

```

it will autobox primitives. This is not a feature of var-args but how types are autoboxed as needed anyway.
"Varargs" are mainly syntactic sugar.

So 

```
Whatever...

```

turns into

```
Whatever[]

```

In other words: the method takes an **array** of the Vararg-type you are using. 

And the compiler makes sure that each and any invocation of a vararg-method receives an array (so the compiler is inserting the `new Whatever[]` more or less for you).

And please note: the fact that your example relies on **auto-boxing** has nothing to do with the fact that you are also using varargs.

If the signature of your method would have been `Object[]` instead, it works the same way (minus the little thingy that you have to pass an array now, instead of just listing your values, separated by comma).