Java Programming Tutorials

Java Programming Tutorials And Articles
  Title / Author Replies
Views
An Applet is a small program that can be sent across the Internet and interpreted on a client machine. To give permission for remote access it must be a public class. Typically it is a class that inherits and/or defines a special set of functions needed to run an applet. These are part of the class...
2
64,968
Java has a class called File, which actually represents not a file you can read or write, but rather a filename. Using this class is highly recommended instead of simple strings, because it makes your file naming operating-system independent. You can easily find out wether a filename is relative or...
0
3,933
When many items of data of the same class or type have to be stored, it is more efficient to use an array than separate variables or objects. For example, if the temperature on each day of the (non-leap) year had to be stored, rather than set up tempjan1, tempjan2... tempdec31 (365 variables)...
2
14,038
Automatic Conversion In Java type conversions are performed automatically when the type of the expression on the right hand side of an assignment operation can be safely promoted to the type of the variable on the left hand side of the assignment. Thus we can safely assign: byte -> short -> int...
0
51,536
Introduction A pattern of special characters is used to specify the format of the date. The example below demonstrates some of the characters. For a complete listing, see the javadoc documentation for the SimpleDateFormat class. Note: This example formats dates using the default locale...
0
18,935
Growing an Array in Java Suppose you have an array of some type that is full, and you want to grow it. Employee a = new Employee; // array is full int newLength = a.length * 11 / 10 + 10; Employee newArray = new Employee; System.arraycopy(a, 0, newArray, 0, a.length); a = newArray;That...
5
19,466
Introduction Assertion facility is added in J2SE 1.4. In order to support this facility J2SE 1.4 added the keyword assert to the language, and AssertionError class. An assertion checks a boolean-typed expression that must be true during program runtime execution. The assertion facility can be...
4
17,779
Introduction Handling character strings in Java is supported through two final classes: String and StringBuffer. The String class implements immutable character strings, which are read-only once the string has been created and initialized, whereas the StringBuffer class implements dynamic...
0
6,460
What Is GlassFish? Depending on how you look at it, GlassFish is any of the following: A community. The GlassFish community currently includes over 1100 members participating in the GlassFish project, with the objective of developing an open source application server that implements Java EE...
0
3,911
Drawing Lines The drawLine method belongs to the Graphics class. This example draws a fan of twenty lines from the bottom center of the Applet along the top edge. The applet's getSize method is used to find the dimensions of the applet. import java.awt.*; import java.applet.*; public...
0
10,381
The Decimal Format class is not very well documented, so I will try and exmplain it with an example. Firstly, you need to import the DecimalFormat class: import java.text.DecimalFormat; Create an instance the format object. This object can be used with doubles, as it uses a decimal. It uses a...
1
6,214
How do I instantiate a bean whose constructor accepts parameters using the useBean tag? Replacing Characters in a String? Searching a String? Connecting to a Database and Strings Handling? What is a transient variable?
1
20,400
Just like the multiple catch blocks, we can also have multiple try blocks. These try blocks may be written independently or we can nest the try blocks within each other, i.e., keep one try-catch block within another try-block. The program structure for nested try statement is: try { //...
0
14,380
Java defines several built-in classes for exception handling. All these classes are a part of the java.lang package which is automatically imported. That is why, while throwing an exception you did not specifically include any package for exception classes. Apart from the built-in exception...
0
23,330
Compiler Problems 1. 'javac' is not recognized as an internal or external command, operable program or batch file If you receive this error, it means that Windows is not able to find the compiler (javac). Here's one way to tell Windows where to find javac. Set the PATH as follows on...
2
12,503
JSTL is a collection of tags similar to HTML that lets you produce dynamic web pages without needing to learn Java. Why JSTL? JavaServer Pages (JSP) technology makes it easy to embed bits of Java code (or scriptlets) in HTML documents. This solution, however, may not be suitable for all HTML...
2
7,674
Comparing Strings To compare strings function equals() is used. String str1 = "XYZ"; String str2 = "xyz"; boolean result = str1.equals(str2); boolean result2 = str1.equalsIgnoreCase(str2);Output
6
14,802
This is a basic digital clock in Java that works off your operating system time, it works in a multithreaded environment and have coded it to put my own background in. import java.awt.*; import javax.swing.*; import java.util.*; class Clock extends JFrame implements Runnable { ...
6
57,346
Introduction The solution is mainly used in Error website wherein you have to generate reports which gives the number of solutions uploaded in a specific period(Reports by calendar) or the number of solutions posted by particular employee (reports by employee id). Background My...
10
3,489
Introduction This Code snippet is used to capture Screenshot automatically and save it. The below code performs the function of taking screenshots automatically making use of the class java.awt.Robot .The package java.awt contains all of the classes for creating user interfaces and for...
7
3,461