call a variable from main method in another - java -
public static void main(string[] args) throws exception { url oracle = new url("http://www.example.com/example.php"); bufferedreader in = new bufferedreader(new inputstreamreader(oracle.openstream())); string inputline; inputline = in.readline(); system.out.println(inputline); in.close(); } i dont know java , trying use first line url string project.
so how can use variable "input line" in same class in method looks this:
public void run(){//content} i appreciate helpful answer. thanks!
first of all, run() method has static.
second, pass parameter it: public static void run(string inputline)
an alternative make static instance field called inputline, , use across methods without needing parameter on run method.
as beginner, must mind-boggling. may want follow "java beginners" tutorials. these basic stuff.
Comments
Post a Comment