1.Hello, I wonder what are the differences between modifiers? Private, public, default, static...? I have reread and reread my java book, but I just can't understand.
6 988
1.Hello, I wonder what are the differences between modifiers? Private, public, default, static...? I have reread and reread my java book, but I just can't understand.
Ok let's have what you think about them first. What did you understand so far?
the best way to learn about them is to use them in your code and see the results(i mean errors).
Ok let's have what you think about them first. What did you understand so far?
...that when a method is static, you cannot change it outside the class. But why is it that the values of variables inside the main( ) can still be changed even if main( ) is declared as static?
...that a public class can be accessed by classes that belong to the other package. Is package related to group? I have not yet developed several program that exist in the same package.
... that if a class uses a default modifer, then only classes on the same package where it belongs, can access that class.
... that if a class has no defined modifier, does it mean it uses a default modifier?
the best way to learn about them is to use them in your code and see the results(i mean errors).
yeah, your right... I will try. Thanks!
...that when a method is static, you cannot change it outside the class. But why is it that the values of variables inside the main( ) can still be changed even if main( ) is declared as static?
...that a public class can be accessed by classes that belong to the other package. Is package related to group? I have not yet developed several program that exist in the same package.
... that if a class uses a default modifer, then only classes on the same package where it belongs, can access that class.
... that if a class has no defined modifier, does it mean it uses a default modifier?
Well this introduce you to these quickly.
In reply to ur confusion regarding "static" before main==>
The JVM is designed such a way that it always finds the function - public static void main(String a[])
to start with.
the keyword static means that the function following needs no "instantiation"
means it dont need any other method to call it for execution.
If this system was not there then u cudnt have run any java program.
just try to run the following - public class Main {
-
public static void main1(String args[])
-
{
-
System.out.println("here");
-
}
-
}
or this code: - public class Main {
-
public void main(String args[])
-
{
-
System.out.println("here");
-
}
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Aphrael |
last post by:
I would like a regular expression to do so:
Base:
<A HREF="somelink" maybesomthing="heretoo">linkface</A>
and I want:
(somelink) linkface
Is this possible ? If yes, how ?
And by the way, if...
|
by: Laurence Nuttall |
last post by:
What is the modifiers property of a label
mean?
I looked in the help, but couldn't find any
explantion for it.
Thanks in Advance,
Laurence Nuttall
Programmer Analyst III
|
by: kchalla |
last post by:
Can anybody let me know the difference between public and private class
access modifiers? Thanks in advance
|
by: Bob Weiner |
last post by:
Is it possible to create a property and specify different access modifiers
for the get and set methods? From the property definition it appears that
you can define attributes but not access...
|
by: Picho |
last post by:
Hi all,
Using reflection, I can invoke/call private methods of an object.
is this intended?
if yes, why? in what scenario (example would be good) should I be givven the
option to use...
|
by: mayfjf |
last post by:
1. Hello, I wonder what are the differences between modifiers? Private, public, default, static...? I have reread and reread my java book, but I just can't understand. Thanks for any info......
|
by: Tom Baxter |
last post by:
Hi everyone,
Has anyone looked at section 18.1.1 of the C# spec? It indicates 'new' and
'protected' are valid modifiers on struct declarations. First, how can
'protected' be valid on a struct,...
|
by: devgupta01 |
last post by:
I have seen the class with public and without modifiers and method with public, protected or private modifiers. I am confused how to decide modifiers for a class?
|
by: sumsin |
last post by:
Is there any difference between 'qualifiers and modifiers?
Or both are synonyms, because in general they are used
interchangeably.
Which is the standard word from language perspective?
What are...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |