Results 1 to 2 of 2
- 12-15-2007, 09:55 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 1
- Rep Power
- 0
Calling method from another class
Hi guys,
i have made two java files as followin:
1st file:
import java.io.*;
public class Reader
{
private static BufferedReader stdin =
new BufferedReader( new InputStreamReader( System.in ) );
public static void main ( String [] args ) throws IOException
{
System.out.println( "input = " + getString());
}
public static String getString() throws IOException
{
String input = stdin.readLine();
return input;
}
}
and the 2nd file is:
public class Test01
{
public static void main(String[] arguments)
{
System.out.println(Reader.getString());
}
}
The problem is that i could'nt call the getString method from Test01 class????
could any one take a look and tell me about it?
thanks
- 12-15-2007, 07:24 PM #2
Senior Member
- Join Date
- Nov 2007
- Location
- Newport, WA
- Posts
- 141
- Rep Power
- 0
Java Code:Reader r = new Reader(); r.getString();
edit:
I misread your code, i didnt notice that getString was static:
Java Code:Reader.getString();
Java Code:private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) );
Similar Threads
-
Calling a method in another class
By uncopywritable in forum New To JavaReplies: 9Last Post: 10-22-2012, 05:01 PM -
Dynamic method calling
By Java Tip in forum Java TipReplies: 0Last Post: 02-15-2008, 09:46 AM -
method calling?
By frejon26 in forum New To JavaReplies: 4Last Post: 01-25-2008, 04:38 AM -
Help with Calling a method
By Albert in forum New To JavaReplies: 3Last Post: 07-10-2007, 04:27 PM
Bookmarks