|
| |||||||||
| Tags: class, do while, java, loop statement, object, program, project |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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. |
|
#2
| ||||
| ||||
| 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();
} Code: public @interfaces MyAnnotarion s{
booleans bool() default trues;
} |
|
#3
| |||
| |||
| 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. |
|
#4
| ||||
| ||||
| 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;
} |
|
#5
| ||||
| ||||
| 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;
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |