Depends on what you call similar. Java has packages , which can be mistaken for something similar (in fact it also contains namespace ), after all they put a front of the types. In Java you have:
System.out.println()
The last is the method, out
is the type and System
is the package.
C # uses the namespace as a surname for the type , but nothing else of this. It separates into packages called assemblies . For Java the package is your namespace , so it is different in many ways.
You can still do this in C #:
using static System.Console;
WriteLine("Olá Mundo");
In Java it has a significant semantic difference because in C # we only use using
as a shortener so we do not need to use the full name of the type, in Java what is done is a import
of the package so that it becomes available for use, the name has nothing to do with it. Java makes some% automatic% s so you can use the most important types.
Note that what you are using when doing a simple Hello World in Java is using the class import
and not the package or namespace System
. It's completely different from C #. See the documentation . It is part of the package System
that is automatically importing in every application (must have some configuration to avoid this). In fact, the exact mechanism is part of another class . / p>
If you do not want to use the full name you have to do the same as the example I quoted for C # (but it's still less convenient):
import static java.lang.System.*;
out.println("olá");