473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I need help on java modifiers, pls.

mayfjf
14
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.
Jan 30 '07 #1
6 988
r035198x
13,262 8TB
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?
Jan 30 '07 #2
hirak1984
316 100+
the best way to learn about them is to use them in your code and see the results(i mean errors).
Jan 30 '07 #3
mayfjf
14
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?
Jan 30 '07 #4
mayfjf
14
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!
Jan 30 '07 #5
r035198x
13,262 8TB
...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.
Jan 30 '07 #6
hirak1984
316 100+
In reply to ur confusion regarding "static" before main==>
The JVM is designed such a way that it always finds the function
Expand|Select|Wrap|Line Numbers
  1. 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
Expand|Select|Wrap|Line Numbers
  1. public class Main {
  2. public  static void main1(String args[])
  3. {
  4.     System.out.println("here");
  5. }
  6. }
or this code:
Expand|Select|Wrap|Line Numbers
  1. public class Main {
  2. public   void main(String args[])
  3. {
  4.     System.out.println("here");
  5. }
  6. }
Jan 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
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...
4
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
3
by: kchalla | last post by:
Can anybody let me know the difference between public and private class access modifiers? Thanks in advance
2
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...
4
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...
11
mayfjf
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......
13
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,...
2
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?
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.