Skip to main content

Posts

Showing posts with the label java keywords

interface Java Keyword

The interface keyword is used to declare a new Java interface, which is a collection of methods. Interfaces are a powerful feature of the Java language. Any class may declare that it implements one or more interfaces, meaining it implements all of the methods defined in those interfaces. Examples public interface IPolygon { public float getArea(); public int getNumberOfSides(); public int getCircumference(); }

import Java Keyword

The import keyword makes one class or all classes in a package visible in the current Java source file. Imported classes can be referened without the use of fully−qualified class names. Examples import java.io.File; import java.net.*;

implements Java Keyword

The implements keyword is used in a class declaration to indicate that the class being declared provides implementations for all methods declared in the interface whose name follows the implements keyword. Examples public class Truck implements IVehicle { }

float Java Keyword

float is a Java primitive type. A float variable may store a single−precision floating point value. Examples float ratio = .01; float diameter = 6.15; float height = 1.35E03; // 1.35 * 103 or 1350.0 float height = 1e−2; // 1.0 * 10−2 or 0.01

finally Java Keyword

The finally keyword is used to define a block that is always executed in a try−catch−finally statement. A finally block typically contains cleanup code that recovers from partial execution of a try block. Examples try { <block that may throw exceptions> } catch (<java.lang.Exception or subclass> e) { <code to handle exception e> } finally { <statements that execute with or without exception> }

extends Java Keyword

The extends keyword is used in a class or interface declaration to indicate that the class or interface being declared is a subclass of the class or interface whose name follows the extends keyword. Examples public class Rectangle extends Polygon { }

else Java Keyword

The else keyword is always used in association with the if keyword in an if−else statement. The else clause is optional and is executed if the if condition is false. Examples if (condition) { <statements> } else { <statements> }

double Java Keyword

double is a Java primitive type. A double variable may store a double−precision floating point value. Examples double ratio = .01; double diameter = 6.15; double height = 1.35E03; // 1.35 * 103 or 1350.0 double height = 1e−2; // 1.0 * 10−2 or 0.01

default Java Keyword

The default keyword is used to label the default branch in a switch statement. Examples int arg = <some value>; switch (arg) { case 1: <statements> break; case 2: <statements> break; default: <statements> break; }