I tried to make a "shortcut" to the print, println, and the scanner. So I created a different class, and that's what it had in it:
import java.util.*;
public class ShortCutClass {
Scanner input = new Scanner(System.in);
public void p (String text){
System.out.print (text);
}
public void pl (String text){
System.out.println (text);
}
public String is (){
String a= input.nextLine();
return a;
}
public double id (){
double b= input.nextDouble();
return b;
}
public int ii (){
int c= input.nextInt();
return c;
}
}
So, I tried to check if it works- using this:
import java.util.*;
class ShortcutTest{
Scanner input = new Scanner(System.in);
public static void main(String args[]){
ShortCutClass scc = new ShortCutClass();
scc.pl("So ummmm... How ya doin?");
scc.p("Connected1 ");
scc.p("Connected2 ");
String a=scc.is;
double b=scc.id;
int c=scc.ii;
scc.pl (a);
scc.pl (b);
scc.pl (c);
}
}
and it gives me the following Error: "cannot find symbol- variable is
What am I doing wrong? How can I fix this?
*** Edit:
I fixed it, and ran into another problem... I can not print out b or c because the print I wrote requires a String, and b and c can only be double and int, so that won't work. is there any way of changing the print (scc.p and scc.pr) so it will be able to receive any kind of parameter?
()is missing.double b=scc.id;should bedouble b=scc.id();.is,idandiiare methods, not variables.