- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 338 Articles for Java Programming
![Abhinaya](https://www.tutorialspoint.com/assets/profiles/13548/profile/60_54851-1512705920.jpg)
669 Views
Using CLASSPATH, you can load any classes at runtime.Like the .java source files, the compiled .class files should be in a series of directories that reflect the package name. However, the path to the .class files does not have to be the same as the path to the .java source files. You can arrange your source and class directories separately, as −\sources\com\apple\computers\Dell.java \classes\com\apple\computers\Dell.classBy doing this, it is possible to give access to the classes directory to other programmers without revealing your sources. You also need to manage source and class files in this manner so that the compiler and the ... Read More
![Sravani S](https://www.tutorialspoint.com/assets/profiles/13538/profile/60_67753-1512711355.jpg)
880 Views
Subpackages are similar to sub-directories. Consider an example. The company had a com.apple.computers package that contained a Dell.java source file, it would be contained in a series of subdirectories like this −....\com\apple\computers\Dell.javaAt the time of compilation, the compiler creates a different output file for each class, interface, and enumeration defined in it. The base name of the output file is the name of the type, and its extension is .class.For example −// File Name:Dell.java package com.apple.computers; public class Dell { } class Ups { }Now, compile this file as follows using -d option −$javac -d.Dell.javaThe files will be compiled as ... Read More
![Ramu Prasad](https://www.tutorialspoint.com/assets/profiles/13539/profile/60_87996-1512650215.jpg)
531 Views
You can understand it using an example where a Boss class is defined in payroll package.package payroll; public class Boss { public void payEmployee(Employee e) { e.mailCheck(); } }if the Employee class is not in the payroll package? The Boss class must then use one of the following techniques for referring to a class in a different package.The fully qualified name of the class can be used. For example −payroll.EmployeeThe package can be imported using the import keyword and the wildcard (*). For example −import payroll.*;The class itself can be imported using the import keyword. ... Read More
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
5K+ Views
You can understand it using an example where a Boss class is defined in payroll package.package payroll; public class Boss { public void payEmployee(Employee e) { e.mailCheck(); } }if the Employee class is not in the payroll package? The Boss class must then use one of the following techniques for referring to a class in a different package.The fully qualified name of the class can be used. For example −payroll.EmployeeThe package can be imported using the import keyword and the wild card (*). For example −import payroll.*;The class itself can be imported using the import ... Read More
![Ankitha Reddy](https://www.tutorialspoint.com/assets/profiles/13550/profile/60_73963-1512711511.jpg)
27K+ Views
Let us look at an example that creates a package called animals. It is a good practice to use names of packages with lower case letters to avoid any conflicts with the names of classes and interfaces.Following package example contains interface named animals −/* File name : Animal.java */ package animals; interface Animal { public void eat(); public void travel(); }Now, let us implement the above interface in the same package animals −package animals; /* File name : MammalInt.java */ public class MammalInt implements Animal { public void eat() { System.out.println("Mammal eats"); } ... Read More
![Nikitha N](https://www.tutorialspoint.com/assets/profiles/13558/profile/60_76068-1512713229.jpg)
4K+ Views
Let us look at an example that creates a package called animals. It is a good practice to use names of packages with lower case letters to avoid any conflicts with the names of classes and interfaces.Following package example contains interface named animals −/* File name : Animal.java */ package animals; interface Animal { public void eat(); public void travel(); }Now, let us implement the above interface in the same package animals −package animals; /* File name : MammalInt.java */ public class MammalInt implements Animal { public void eat() { System.out.println("Mammal eats"); } ... Read More
![Kiran Kumar Panigrahi](https://www.tutorialspoint.com/assets/profiles/390736/profile/60_2598-1635242143.png)
11K+ Views
Classes are the fundamental building blocks of Java. It is a programmable template that can be expanded upon, and it determines the form and characteristics of an item. One may say that a class is the most fundamental component of an object oriented programming language like Java. Each and every idea that will be put into action by means of a Java application must first be encased inside of a class. In object-oriented programming, the fundamental building blocks are called classes objects.Variables and methods are the building blocks of a Java class. Instance variables are the terms used to refer ... Read More
![Sravani S](https://www.tutorialspoint.com/assets/profiles/13538/profile/60_67753-1512711355.jpg)
6K+ Views
Yes! Java supports constructor overloading. In constructor loading, we create multiple constructors with the same name but with different parameters types or with different no of parameters.ExampleLive Demopublic class Tester { private String message; public Tester(){ message = "Hello World!"; } public Tester(String message){ this.message = message; } public String getMessage(){ return message ; } public void setMessage(String message){ this.message = message; } public static void main(String[] args) { Tester tester = new Tester(); System.out.println(tester.getMessage()); Tester tester1 = new Tester("Welcome"); System.out.println(tester1.getMessage()); } } OutputHello World! Welcome
![Janani Jaganathan](https://www.tutorialspoint.com/assets/profiles/506990/profile/60_3923617-1661405985.jpg)
12K+ Views
Anonymous object in Java means creating an object without any reference variable. Generally, when creating an object in Java, you need to assign a name to the object. But the anonymous object in Java allows you to create an object without any name assigned to that object. So, if you want to create only one object in a class, then the anonymous object would be a good approach. Reading this article, you will learn what an anonymous object is and how to create and use anonymous objects in Java. Let's get started! Anonymous Object in Java Anonymous means Nameless. An ... Read More
![Ankitha Reddy](https://www.tutorialspoint.com/assets/profiles/13550/profile/60_73963-1512711511.jpg)
1K+ Views
You can create a List of object easily. Consider the following example, where I'll create an array of Employee objects and print their details in a for loop. import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; public class Tester implements Cloneable { private int data; public int getData() { return data; } public void setData(int data) { this.data = data; } public Tester(int data){ ... Read More