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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -