Well, my question is very simple. In C ++ I do this:
using namespace std;
Then I can use the strings. What I would like to know is, if there is something in Java to import all the functions of a class.
Now, what I do is call the functions of the class as if they were properties, like this:
Sistema.pedirTeclado()
But I'd like to use the function without writing Sistema
, like this.
pedirTeclado()
Edit:
When I make a folder, and I put the function inside that folder, then it works for me, but when I put all the functions in a class, it does not work for me.
Is there a way to import all the functions of a single file .java
?
My file Sistema.java
is this.
package programa;
import java.util.Scanner;
public class Sistema
{
public static int pedirTeclado(Scanner teclado)
{
int número = teclado.nextInt();
return número;
}
public static int pedirTecladoDiferente(Scanner teclado,int número)
{
boolean permanece;
while(permanece)
{
int númeroTeclado = teclado.nextInt();
if(número!=númeroTeclado){permanece = false;}
}
return número;
}
}
I tried to create the functions outside the class Sistema
, but it does not leave me either.