concept line in category java

appears as: line, line, lines, The lines, lines, The line
Java SE 11 Programmer I Certification Guide

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide.

You can add comments in your source file. A comment can appear before and after a package statement, within a class definition, or a method definition. Comments come in two flavors: multiline comments and end-of-line comments.

public class Prim {                                // line 1
    public static void main(String[] args) {       // line 2
        char a = 'a';                              // line 3
        char b = -10;                              // line 4
        char c = '1';                              // line 5
        integer d = 1000;                          // line 6
        System.out.println(++a + b++ * c - d);     // line 7
    }                                              // line 8
}                                                  // line 9
Figure 12.7 Tracing the line of code that threw an exception at runtime
Get Programming with Java

This is an excerpt from Manning's book Get Programming with Java.

Every Java project must include at least one file that contains a main method. In our first program, line 3 is the start of this method.  The main method extends from line 3 where it starts with an open curly brace and ends on line 5 with a closing curly brace. In the next few lessons, we will talk more about exactly what each line of code is doing in this example. 

Before we run this new program, let’s add a line of code so we can see it print information to the console.  The console is also part of the IDE. Keeping it simple, replace the comment on line 4 that currently says // TODO code application logic here with this line of code:

System.out.println(“Java Rocks!!”);

Make sure that you type the line of code exactly as it appears above. Java is case-sensitive, so you must use a capital S for System and lower case for the remaining command.  The words inside the double quotes can be mixed case - they are considered a literal constant.  Next, we want to save the program, make sure that you don’t change the file name.  In Java, the file name must match the class name exactly.  Once you are done, click the green arrow to the right of the hammer and brush. You should see output similar to Figure 1.9.

OCA Java SE 8 Programmer I Certification Guide

This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.

As you can see, oldLaptops[3] is an array of 10 uninitialized String objects. All the members (from index position 0 to 9) of the array oldLaptops[3] are assigned a null value. The code on line 4 tries to call the method length on the first element of array oldLaptops[0], which is null, throwing a NullPointerException.

public class Foo {
    public static void main (String args[]) {
        boolean b1, b2, b3, b4, b5, b6;    // line 1
        b1 = b2 = b3 = true;               // line 2
        b4 = 0;                            // line 3
        b5 = 'false';                      // line 4
        b6 = yes;                          // line 5
    }
}
The code on line 1 will fail to compile.
Can’t initialize multiple variables like the code on line 2.
The code on line 3 is correct.
Can’t assign 'false' to a boolean variable.
The code on line 5 is correct.
  • Inheritance enables you to reuse existing code.
  • Figure 7.7. Tracing the line of code that threw an exception at runtime
    JavaFX in Action

    This is an excerpt from Manning's book JavaFX in Action.

    While other RIA technologies blur the line between desktop and browser, JavaFX removes the distinction entirely. A single JavaFX application can move seamlessly (quite literally, by being dragged from the browser window) from one environment to the other. Desktop, applets, and smart phones can already be targeted, while Blu-ray and other TV devices are expected to join this list at a later date. With a common core across all environments, complemented by device-specific extensions, JavaFX lets us target every device or exploit the full power of a particular device.

    Figure 5.12. Version 2 of the project application, featuring both swirling lines and raindrops

    For every Dilbert, there’s a Pointy-Haired Boss, or so it seems. As programmers interested in graphics, we naturally want to spend our time writing video effects, UI controls, and Pac-Man clones; unfortunately, our bosses are unlikely to let us. When bosses say “graphics” they generally mean charts and graphs, and that’s probably why the 1.2 release of JavaFX came with a collection of ready-made pie, bar, line, and other chart controls (like the 3D pie chart in figure 7.7).

    The LineChart is the familiar graph we all remember from school. Using x and y values, it plots a line to connect the dots.