Classes and Objects
A class is an essential element of any application written in Java. Java program is a collection of classes. The definition of each class is placed in a separate file, which is the file must have the same name as the class and have the extension java.
A program written in Java so it is a collection of files with the extension java, each of these files contains a class definition.
A class is a definition of a kind of entities. Entities that have certain characteristics, behavior and skills. Class is a named set of methods and variables.
A class is the definition of being (being kind), but only instance of the class, ie. The object reflects the concrete being.
By implementing the application in the Java language we define a new class, but also – use class library that is implemented by someone else. A special library (a set of classes) is a standard library. The standard library includes classes that implement basic functionality, for example. Classes for manipulating disk files. Class standard library are described within the specifications of Java SE.
The following code fragment demonstrates the use of the File class derived from the standard library (library Java SE). File class represents any collection or disk file or directory. To check whether the set of disk defined by a path – in our case C: /mydir/file.txt – exists and that the file is sufficient to create an object of class File, and then call on the object method ISFILE (). The method call ISFILE () use to display the appropriate message.
File file = new File ( “C: /mydir/file.txt”);
if (file.isFile ())
System.out.println (“file found!”);
System.out.println (“The specified file does not exist!”);