java - Use a string from an outside class to the main class -
i have main class file calls methods objects other outside class files.
i'm having hard time using string in main class file defined in outside class file.
this main class:
import java.util.scanner; public class tw5k { public static void main(string[] args) { citenum citenumber = new citenum(); platenum platenumber = new platenum(); datenum datenumber = new datenum(); citenumber.citeent(); platenumber.plateent(); datenumber.dateent(); system.out.println(); // want print string "dateld" here, outside class. } }
this outside class:
import java.util.scanner; public class datenum { public void dateent() { scanner input = new scanner(system.in); system.out.print("enter date of violation: "); string dateld = input.nextline(); system.out.println(); } }
return value:
public string dateent() { scanner input = new scanner(system.in); system.out.print("enter date of violation: "); string dateld = input.nextline(); system.out.println(); return dateld; }
then:
string dateld = datenumber.dateent(); system.out.println(dateld);
Comments
Post a Comment