Results 1 to 9 of 9
Thread: How to use class in if condition
- 03-08-2012, 11:39 AM #1
Senior Member
- Join Date
- Jan 2012
- Location
- TamilNadu
- Posts
- 162
- Rep Power
- 2
How to use class in if condition
Hi
i need help!
in my project i use packages(core [sub-package] & data [sub-sub-package])
inside the sub-sub-package i have two classes CryptoFileData & PlainFileData
and
i wants to use above classes in another sub-package called gui
i import the classes too..,
but it showing error in the fallowing code (core/data/CryptoFileData)
Java Code:if(currentData.getClass() == core/data/CryptoFileData) { CryptoFileData data = (CryptoFileData)currentData; File outPath = new File(tf_rOutput.getText()); data.setOutputFile(outPath); data.SetPassword(PwdDialog.getPasswordFromUser()); }
if i use (core.data.CryptoFileData) formate also showig error
can anyone give the solution please..,
- 03-08-2012, 12:05 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: How to use class in if condition
You need to show us the errors.
Anyway, in this case it's <class name>.class to get the Class instance.Please do not ask for code as refusal often offends.
- 03-08-2012, 12:28 PM #3
Senior Member
- Join Date
- Jan 2012
- Location
- TamilNadu
- Posts
- 162
- Rep Power
- 2
Re: How to use class in if condition
Thank you Mr.Tolls..,
I try for as your idea..,
Thank you Sir..,
- 03-08-2012, 12:51 PM #4
Re: How to use class in if condition
The instanceof keyword is there for a purpose. Even if, sadly, its use exposes a faulty or weak design. As does testing the class of a parameter in any other way.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 03-08-2012, 01:12 PM #5
Senior Member
- Join Date
- Jan 2012
- Location
- TamilNadu
- Posts
- 162
- Rep Power
- 2
Re: How to use class in if condition
i am very happy with your help sir,
i will try to make better design sir..,
thank you..,
- 03-08-2012, 02:38 PM #6
Senior Member
- Join Date
- Jan 2012
- Location
- TamilNadu
- Posts
- 162
- Rep Power
- 2
Re: How to use class in if condition
Thanks to Jesus!
Thank you sir!.gif)
I have been trouble with my coding.
Now!
After your idea, i got my output..,
I lot of thank to you...,
thousands of thanks to you my helper...,
But!
i am using Netbeans IDE & created my project in (e://raj/sec)
if i create a jre,
i can only execute in side the Netbeans Or on the folder (wher i keep my project path (dist folder)) Or create shortcut from their
but!
if i copy the jar to desktop it show an error (Java Exception has occurred)
what i have to do sir..,
- 03-08-2012, 02:40 PM #7
Re: How to use class in if condition
Again, you have to show us the error. But it sounds like it could be a problem with your classpath or a relative path.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 03-08-2012, 02:56 PM #8
Senior Member
- Join Date
- Jan 2012
- Location
- TamilNadu
- Posts
- 162
- Rep Power
- 2
Re: How to use class in if condition
jest in my if statement to use the class like
is this the problem sir?..,Java Code:if(currentData.getClass() == core.data.CryptoFileData.class) { CryptoFileData data = (CryptoFileData)currentData; File outPath = new File(tf_rOutput.getText()); data.setOutputFile(outPath); data.SetPassword(PwdDialog.getPasswordFromUser()); }
- 03-08-2012, 03:53 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Accessing specific class if condition is true
By Hash in forum New To JavaReplies: 1Last Post: 02-24-2012, 03:43 AM -
Condition ignored.
By Pojahn_M in forum New To JavaReplies: 8Last Post: 12-09-2011, 02:21 AM -
Waiting on a condition
By nephos in forum New To JavaReplies: 9Last Post: 04-22-2011, 10:05 AM -
While loop condition
By counterfox in forum New To JavaReplies: 3Last Post: 10-10-2010, 01:14 AM -
IF-Condition in a String
By lenaz in forum Advanced JavaReplies: 1Last Post: 07-18-2009, 12:07 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks