What is white space explain proper use of white space java, JAVA Programming

Assignment Help:

What is White Space? explain proper use of white space in java?

White space consists mainly of the space character in which you generates through hitting the space bar on your keyboard and in which is generally used to separate words within sentences. There are four other white space characters in Java, the horizontal tab, the create feed, the carriage return, and the linefeed. Depending on your platform, while you hit the return or enter key, you obtain either a carriage return (the Mac), a linefeed (Unix) or both (DOS, Windows, VMS). This generates a hard line break within the source code text.
Outside of String literals Java treats all white space and runs of white space (more than one white space character within immediate succession) the similar. It's used to separate tokens, and one space is as excellent as seven spaces, a tab and two carriage returns. Exactly that white space characters you use is primarily a result of what's convenient for human beings reading the code. The compiler doesn't care.

Inside String and character literals the just white space permitted is the space character. Carriage returns, tabs, line feeds and form feeds must be inserted along with special escape sequences like \r, \t, \f, and \n. You cannot break a String across a line like this:

String poem = "Mary had a little lamb
whose fleece was white as snow
and everywhere that Mary went
the lamb was sure to go.";
Instead you must use \n and the string concatenation operator, +, like this:
String poem = "Mary had a little lamb\n" +
"whose fleece was white as snow\n" +
"and everywhere that Mary went\n" +
"the lamb was sure to go.";

Remember that you can break a statement across multiple lines, you only can't break a String literal.
Also note that \n only works on Unix. You should probably use System.getProperty("line.separator") instead to return the proper line separator string for the platform your program is running on.

Java does not have all the escape sequences C has. Besides those already described it has only \b for backspace, \\ for the backslash character itself.

There are also \u escapes in which let you include any Unicode character.

The proper use of white space in programs
• Blank lines to separate blocks
• Use spaces instead of tabs


Related Discussions:- What is white space explain proper use of white space java

Why you don''t need to import java.lang.*, Why You don't need to import jav...

Why You don't need to import java.lang.* There is one exception to the import rule. All classes in the java.lang package are imported by default. Therefore you do not required

Illustrate the method to print on the GUI, Illustrate the method to print o...

Illustrate the method to print on the GUI Example Code: Taking Input / Output So far, we learned how to print something on console. Now time has come to learn how to print

Demonstrate java client and server , There is no separate homework this wee...

There is no separate homework this week, but you may complete the exercises ahead of time, in which case you only need to attend for long enough to get your work marked off by your

Universal android and ios, Universal Android and iOS, Multipurpose Testing ...

Universal Android and iOS, Multipurpose Testing Application - Based on Phonegap Project Description: Universal Android and iOS, Multipurpose Testing Application Based on Phon

What are the non-final functions in java object class?, The non-final funct...

The non-final functions are clone (), finalize (), toString (), equals () , hashCode () and. The other methods like wait (), getClass (), notifyAll (), notify () etc are final

Preemptive scheduling and time slicing, In pre-emptive scheduling, the high...

In pre-emptive scheduling, the highest priority task implements until it enters the waiting or dead states or a higher priority task comes into existence. In time slicing, a tas

Explain the library java.lang.math, Explain the library java.lang.Math ? ...

Explain the library java.lang.Math ? The Java class library is huge. We will not cover it all presently. In fact, the remaining eight classes will focus mostly on the class lib

#, Consider the following code? What input is needed for x in order for the...

Consider the following code? What input is needed for x in order for the sum variable that is output at the end of the code to be 12 ? (In other words: what do I need to make X be

How would you interact between servlets and applets? , We may use the java...

We may use the java.net.URL and java.net.URLConnection classes to start a standard HTTP connection and "tunnel" to a Web server. The server then gives this information to the s

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd