473,513 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why use dot operator in system.out.println statement

1 New Member
In java program when we write to print something we use one statement I.e. system.out .println. so why we use dot in that
May 13 '14 #1
4 3156
Luuk
1,047 Recognized Expert Top Contributor
Because if we do not use a dot, than Java will not work?
May 13 '14 #2
chaarmann
785 Recognized Expert Contributor
The dots separate class name, field and method.

Just imagine you write only the first name of your friend on a letter and send it away, will he get it? So why do you need to add city and last name? The java dot is the same case.
There are many "out" fields in different classes, so you must say that you want the one from class "System". The "out" field has many methods, so you must say that you want the method "println".
May 14 '14 #3
Luuk
1,047 Recognized Expert Top Contributor
But that's not an answer to "why use dot operator"

Or is that my language problem with English ;)

I mean, also '/' could me used i.e.:
System/out/println("Hello");
May 15 '14 #4
chaarmann
785 Recognized Expert Contributor
But "/" already means division!
So if you write "x=a/b" the compiler does not know if you mean "x equals a divided by b" or "x equals field b of object a". That means it's ambigious.
Let's look for other possible characters:
  • "-": ambigious (subtraction)
  • "_" underscore: ambigious, already part of variable name
  • " " Space: Does not optically separate. Two or more spaces, which is hard to count, would not separate. Also ambigious "a instanceof b" could mean "a.instanceof.b"
  • "\" backslash: not available on most keyboards in the past. Also nowadays you must press "alt" and "?" (on German keyboard) together to print it, so it's hard to type.

Java syntax is derived from C syntax, and in C the dot already had the meaning of accessing a sublement of an element ("struct"), so it was just re-used, but in a slightly different meaning: "a.b" in java matches more the C-syntax "a*.b" instead to "a.b".
May 16 '14 #5

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

Similar topics

0
1809
by: Sanket | last post by:
I have a java application, which generates a html file. Here is how main method looks like public static void main(String args) { //Create a new file using File class. //Make backend calls and...
2
1511
by: JustSomeGuy | last post by:
I have a matrix class that I want to add this method to. basically I want to multiply a matrix by a matrix or by a constant. However, I don't want to return a matrix (refrence) from the method...
2
288
by: Tony Johansson | last post by:
Hello!! If I have part of the assignment operator below. This statement check the addresses "if (this != &v)" and control so you haven't assignt to your self. Could I have checked the actual...
14
2207
by: gupta.keshav | last post by:
Hi, I want to know the trick of implementing condition operator or (if()... else...). Symbols to use: ~, !, ^,&, +, |, <<, >>. NOt to use: if statement, loops,
2
1304
by: danthman | last post by:
Can someone tell me why the following VB.NET code doesn't work? ----- Imports System.Data.SqlClient Partial Class PageHeader Inherits System.Web.UI.UserControl Public ConnectionObjG As...
9
1599
by: Raj | last post by:
public static void HandleException(ref Exception io_exException, bool i_blnPropagateException) { switch (true) { case io_exException is ApplicationHandledException: { if...
11
1449
by: Janus | last post by:
Hi, This is a very basic question. What will happen if there is a statement with a relational operator outside while, for, or if conditions? Something like this... ..
2
2042
by: Randy Smith | last post by:
Hi ALL, I am getting this strange warning message, and I can't seem to find any solution for it. 'System.Configuration.CofigurationSettings.AppSettings is obsolete: it has been replaced by...
1
1869
by: donbell | last post by:
1. What are the following module that we use in accounting system? 2. What is the significance of accounting system? 3. Can you give us, some objectives in accounting system? 4. For some, please...
9
2937
by: lawpoop | last post by:
I'm trying to write some simple code, but I might be simplifying it too much. I have a function that either returns a string that I want, or FALSE. In the code that I'm working on, I would like...
0
7267
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7175
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
7391
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
5697
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,...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4754
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.