Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Small help needed Posted by javabeg on 15 Mar 2011 at 3:10 AM
I'll show u a part of my code. plz help me out.

Package aaa;
It has two java classes.
1) class a(a.java)
2) class b(b.java)

The output of class a is a String s;
I want to use this String s in class b.java

Can u help me write the code.?

Thanks in advance.
Report
Re: Small help needed Posted by skaa7 on 15 Mar 2011 at 10:20 AM
For example this way:

a.java
package ptCCV;

public class a
{
public String s="abcd";
}


b.java
package ptCCV;

public class b
{
public b()
{
a oa=new a();
System.out.println("e:["+oa.s+"]");
}
}

Report
Re: Small help needed Posted by javabeg on 15 Mar 2011 at 11:03 AM
Thanks a lot!!! :)
Report
Re: Small help needed Posted by javabeg on 16 Mar 2011 at 1:00 AM
It says "non-static variable op cannot be referenced from a static context".

op is the name of the variable i used. In ur example it is s.
Report
Re: Small help needed Posted by skaa7 on 16 Mar 2011 at 6:43 AM
I use this way:

package ptCCV;

public class cmain
{
public static void main(String[] args)
{
b ob=new b();
}
}


Maybe I did not understand what you need? Let me know if you have questions!
Report
This post has been deleted. Posted by SundayForever on 22 Mar 2011 at 6:34 PM
This post has been deleted.
Report
Re: Small help needed Posted by nbfelicia on 23 Mar 2011 at 1:28 PM
Hello, post here your code ... so it's easier to tell what's wrong with it..



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.