# Static Typing and Java Interoperability

Xtend, like Java, is a statically typed language. In fact it completely supports Java's type system, including the primitive types as int or boolean, arrays and of course all classes, interfaces, enums and annotations that reside on the classpath.

Java generics are fully supported as well: You can define type parameters on methods and classes and pass type arguments to generic types just as you are used to from Java. The type system and its conformance and casting rules are implemented as defined in the Java Language Specification.

## Type Inference

One of the problems with Java is that you are forced to write type signatures over and over again. That is why so many people do not like static typing. But this is in fact not a problem of static typing but simply a problem with Java. Although Xtend is typed just like Java, you rarely have to write types down because they can be computed from the context.

## Conversion Rules

In addition to Java's autoboxing to convert primitives to their corresponding wrapper types (e.g. int is automatically converted to Integer when needed), there are additional conversion rules.

Arrays are automatically converted to List<ComponentType> and vice versa. That is you can write the following:

def toList(String[] array) {
val List<String> asList = array
return asList
}

Another very useful conversion applies to lambda expressions. A lambda expression usually is of one of the types listed in Functions (src) or Procedures (src). However if the expected type is an interface with a single method declaration, a lambda expression is automatically converted to that type. This allows to use lambda expressions with many existing Java libraries. See section closureTypes for more details.

## Interoperability with Java

Resembling and supporting every aspect of Java's type system ensures that there is no impedance mismatch between Java and Xtend. This means that Xtend and Java are 100% interoperable. There are no exceptional cases. You do not have to think in two worlds. You can call Xtend code from Java and vice versa without any surprises or hassles.

As a bonus if you know Java's type system (specifically generics), you already know the most complicated part of Xtend.