473,323 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Call method from another class

1
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
Dec 15 '07 #1
3 7542
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
import java.io.*;
public class Test01
{
public static void main(String[] args) throws IOException
{
System.out.println(Reader.getString());
}
}
now try ,It will work.
Dec 15 '07 #2
karthickkuchanur
156 100+
import java.io.*;
public class Test01
{
public static void main(String[] args) throws IOException
{
System.out.println(Reader.getString());
}
}
now try ,It will work.

hai
u have to inherit the parent class
Dec 15 '07 #3
JosAH
11,448 Expert 8TB
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?
It's a compilation problem right? The compiler complains that it can't find a Reader
class. Next time when you're stuck show us exactly what your compiler showed you.
Fire up javac like this for starters:
Expand|Select|Wrap|Line Numbers
  1. javac -help
  2.  
You'll see that you can set a classpath where your already compiled classes are
stored. Javac needs that path to be able to read your compiled Reader class and
check whether or not you've been cheating or goofing etc.

It has nothing to do with parent classes or what else; your compiler wants to know
where that Reader class is; no more no less.

kind regards,

Jos
Dec 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ian | last post by:
I have written this utility class that has a method which calls another method. I don't want to pass in the self parameter and was wondering by doing this does it make the function to be private...
2
by: FAN | last post by:
I want to define some function in python script dynamicly and call them later, but I get some problem. I have tried the following: ################################## # code...
5
by: TS | last post by:
From my presentation layer, I call a validation method in my business layer that i pass a custom class to that holds all parameters. I am currently also passing an error message by reference so...
46
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or...
6
by: HolyShea | last post by:
All, Not sure if this is possible or not - I've created a class which performs an asynchronous operation and provides notification when the operation is complete. I'd like the notification to be...
2
by: Jack | last post by:
Hello, I have a 3-level class hirarchy: 1=Grandparent 2=Parent 3=Child The Grandparent has a method called OnPaint which I want to override from the Child class. I can do this, but how...
2
by: mahi543 | last post by:
how can we call one class main method from another class main method? i tried but i got an idea for method we can call one method from another method
1
by: Mike | last post by:
I have an web page (page1.aspx) that has a method in the code behind that I want to call from another page. Is this possible to do? The method resides in the page1.aspx.cs file, its a public...
5
by: RP | last post by:
I have a function to fill combo box items. I pass SQL query and combo box name as arguments. This function is located in another class. In my Form, I have declared a delegate to this function...
6
by: Christopher | last post by:
Its been awhile and I am rusty. Can the constructor of my class call another method in the same class if that other method does not change any member data? I want to simply have a seperate...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.