| | |
How to Access a Public Filed from a class and that Field value From the other Class
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2008
Posts: 26
Reputation:
Solved Threads: 1
How to Access a Public Filed from a class and that Field value From the other Class
0
#1 Nov 28th, 2008
Hi Frnds,
Sorry For The Spam .
i have a class name"Super"
program: ---------------------------------------------------------------------------------
but when iam printing the value of platformFlag from the class Model it is printing null..
.?
could anyone of here tell me wat is the reason .
and Tell me the rway how to print value as sekhar
Sorry For The Spam .
i have a class name"Super"
program:
Java Syntax (Toggle Plain Text)
package turn; public class Super { public static String platformFlag=null; public void parse() { platformFlag="Sekhar"; } public static void main(String args[]) { Super ob=new Super(); ob.parse(); } } ------------------------------------------------------------------------------- Now i have another class in the same package package turn; public class Model { public void result(Super dupObj){ :'( System.out.println("Value of platformFlag" +dupObj.platformFlag); } public static void main(){ Model my=new Model(); Super sObject = new Super(); my.result(sObject); } }
but when iam printing the value of platformFlag from the class Model it is printing null..
.?
could anyone of here tell me wat is the reason .and Tell me the rway how to print value as sekhar
Last edited by ~s.o.s~; Nov 28th, 2008 at 9:00 am. Reason: Added code tags, learn to use them.
Re: How to Access a Public Filed from a class and that Field value From the other Class
0
#2 Nov 28th, 2008
your app bit more OO-minded
Java Syntax (Toggle Plain Text)
package turn; public class Super { private String platformFlag=null; public Super(){ setPlatformFlag("sekhar"); } public void setPlatformFlag(String in){ this.platformFlag = in; } public String getPlatformFlag(){ return this.platformFlag; } }
Java Syntax (Toggle Plain Text)
package turn; public class Model { public void result(Super dupObj){ System.out.println("Value of platformFlag" + dupObj.getPlatformFlag()); } public static void main(){ Model my=new Model(); Super sObject = new Super(); my.result(sObject); } }
Last edited by stultuske; Nov 28th, 2008 at 8:53 am. Reason: access identifier corrected
Re: How to Access a Public Filed from a class and that Field value From the other Class
0
#3 Nov 28th, 2008
@babusek
This is your twentieth post and still you have not used code tags. Are you just plain ignorant to not go through the Community rules or the Announcements or at least observe how other posters post in the forum.
This is your twentieth post and still you have not used code tags. Are you just plain ignorant to not go through the Community rules or the Announcements or at least observe how other posters post in the forum.
Last edited by stephen84s; Nov 28th, 2008 at 8:50 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
![]() |
Other Threads in the Java Forum
- Previous Thread: Commapi serial port close/open
- Next Thread: how to send message via bluetooth
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component converter database digit eclipse equation error event exception fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying page pearl print problem program programming project qt recursion scanner screen scrollbar server set size sms sort spamblocker sql sqlserver string superclass swing system thread threads tree variablebinding windows xor






