Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , , ,

Sponsored Links



How to use same keyword for two purposes in java?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 67
How to use same keyword for two purposes in java?

Hello friends,
We know that "default" keyword is used as access specifier and we can also used it in switch statements for complete different purpose. So I want to know that is there any other keywords in java, which can used for different purpose. If yes, then can anyone tell me how to use same keyword for two purposes in java? Please help me.
Thank you.
Reply With Quote
  #2  
Old 08-03-2010
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,937
Re: How to use same keyword for two purposes in java?

Hey it seems that you get wrong information "default" is mot the keyword, because you can not write like "default void format()"
You can declare it in following ways.
Code:
switch (as) {
   defaults: somethings();
}
and
Code:
public @interfaces MyAnnotarion s{
    booleans bool() default trues;
}
In the above code I have use "default" in different ways.
Reply With Quote
  #3  
Old 08-03-2010
Member
 
Join Date: May 2008
Posts: 1,990
Re: How to use same keyword for two purposes in java?

As per my information you can not use "default" as access specifier. So it means that you can not use "default" keyword for different purpose. You can only use such type of keywords in annotations. You can use "final" keyword to do this. It can not be derived from overridden. It can also use as read-only member.
I hope my suggestion will help you.
Reply With Quote
  #4  
Old 08-03-2010
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,976
Re: How to use same keyword for two purposes in java?

You have use default keyword as access specifier and that's why you are getting such type of problem. As per my information you can not use default keyword as an access specifier. When you don't use private, protected and public, then only default is used.
For example:
Code:
class TestEg { // default class 

 int As; 
}
Reply With Quote
  #5  
Old 08-03-2010
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
Re: How to use same keyword for two purposes in java?

As per my information you can not use one keyword for more than two purpose. I think you can use static keyword to do this. This keyword associates methods and access instances of that class. You have to use following example to do this.
Code:
public class MyClassEg
{
   private static int as1;

   static
   {
      as1 = 1;
   }
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to use same keyword for two purposes in java?"
Thread Thread Starter Forum Replies Last Post
Final keyword in Java Level8 Software Development 4 26-10-2011 09:04 PM
Equivalent to Java finally keyword in PHP Jaganmohini Software Development 6 12-08-2010 11:20 AM
Keyword Analyzer and keyword ranking tool Captain Carrot Technology & Internet 5 21-06-2010 04:12 PM
For what purposes do you use Piracy Reegan Polls & Voting 5 26-01-2009 05:02 PM
How to use Search Engine Keyword Tracker & Keyword Ranking Code using PHP Burnet Software Development 3 09-01-2009 01:38 PM


All times are GMT +5.5. The time now is 03:49 AM.