Escolar Documentos
Profissional Documentos
Cultura Documentos
Basic
Data Type
Math Function
String Function
Basic
import java.io.*;
class AllEvenNum{
public static void main(String[] args) {
try{
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number : ");
int num = Integer.parseInt(br1.readLine());
System.out.println("Even Numbers:");
for (int i=1;i <=num ; i++){
if(i%2==0 ){
System.out.print(i+",");
}
}
}
catch(Exception e){}
}
}
import java.io.*;
class CircleArea{
public static void main(String[] args){
int r=0;
try{
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Radius of Circle : ");
r = Integer.parseInt(br1.readLine());
double area = java.lang.Math.PI*r*r;
System.out.println("Area of Circle : "+area);
double perimeter =2*java.lang.Math.PI*r ;
System.out.println("Perimeter of Circle : "+perimeter);
}
catch(Exception e){
System.out.println("Error : "+e);
}
}
}
import
buffered reader which all the input data are stored and modified
input streamreader
integer.parseint parses the string character into decimal integer
readline
try
avoid any kind of input error
catch(Exception e)
java.lang.Math.PI*r*r;
Data Type
Primitive Data Types
Keyword Description Size/Format
Integers
byte Byte-length integer 8-bit two's complement
short Short integer 16-bit two's complement
int Integer 32-bit two's complement
long Long integer 64-bit two's complement
Real numbers
float Single-precision floating point 32-bit IEEE 754
double Double-precision floating point 64-bit IEEE 754
Other types
char A single character 16-bit Unicode character
boolean A boolean value (true or false) true or false
byte byteident = 3;
short shortident=100;
int intident = 10;
long longident = 40000;
char charident = 'a';
String stringident = "chandan";
float floatident = 12.0045f;
double doubleident = 2333333.000000000033343343434f;
Math Function
Function Explanation
This is E field of the Math class which returns you a default exponent
value that is closer than any other to e, the base of the natural
E logarithms.
This is also a field of the Method class which returns you a default pi
PI value, the ratio of the circumference of a circle to its diameter.
abs() This is the abs() function which returns you the absolute number.
This is the ceil() function which returns you the smallest value but greater
ceil() than the argument.
This is the exp() function which returns you the exponential value raised
exp() to the power of a double value.
This is the floor() function which returns you the largest value but less
floor() than the argument.
This is the IEEEremainder() which returns you the remainder for the given
IEEEremainder() dividend and divisor.
This is the max() function which distinguishes the maximum value from
max() the two given value.
This is the min() function which distinguishes the minimum value from
min() the two given value.
This is the pow() function which returns you the number raised to the
pow() power of a first given value by the another one.
This is the random() function which returns you the random number. It is
random() absolutely systemgenerated.
This is the rint() function which returns you a value closest to the given
rint() value.
This is the round() function which returns you a value that is in the
round() rounded form.
This is the sqrt() function which returns you the square root of the
sqrt() specified value.
String Function
Function
append()
insert()
reverse()
setCharAt()
charAt()
substring()
deleteCharAt()
length()
delete()
capacity()
Explanation
This is the append() function used for the concatenate the string in string buffer. This is better to use for dynamic string
concatenation. This function works like a simple string concatenation such as : String str = str + "added string";.
This is the insert() function used to insert any string or character at the specified position in the given string.
This is the reverse() function used to reverse the string present in string buffer.
This is the setCharAt() function which is used to set the specified character in buffered string at the specified position of the
string in which you have to set the given character.
This is the charAt() function which is used to get the character at the specified position of the given string.
This is the substring() function which is used to get the sub string from the buffered string from the initial position to end
position (these are fixed by you in the program).
This is the deleteCharAt() function which is used to delete the specific character from the buffered string by mentioning that's
position in the string.
This is the length() function is used to finding the length of the buffered string.
This is the delete() function is used to delete multiple character at once from n position to m position (n and m are will be
fixed by you.) in the buffered string.
This is the capacity() function is used to know about the current characters kept which is displayed like : number of characters
+ 6.
bin
demo
include
jre
lib
sample
COPYRIGHT
LICENSE
LICENSE.rtf
README.html
src.zip
THIRDPARTYLICENSEREADME
The bin directory provides all inessential tools for developing and testing the program through the help of command provided
This directory consists many applications and applets with source code.
It contains all header files like for 'C' programming language that enables you to combine C code into a Java program.
When you run any java program then you have to compile it by the help of Java interpreter or Java Runtime Environment (JRE
adaptation of JRE, which containing in the jre root directory.
This is a most important directory for development tools that contains libraries and it's supported files.
The jdk1.5.0 directory provides an html file that contains the detail information of SDK shown on the web browser. This file co
features and documentation links to represents all information's about the jdk1.5.0.
The zip file is a collection of one of more files that has been compressed or stored to '.zip' extension. Similarly, the scr.sip file c
It become necessary to extract the file that contain the source code from the ZIP file.
class HelloWorld { lower Proper
public static void main(String[] args){ class
System.out.println("Hello World!"); public static void main (
} out.println("our text!");
}
}
Name File Name like HelloWorld
(String[] args) {
System.
}
Class
BufferedInputStream
BufferedOutputStream
BufferedReader
BufferedWriter
ByteArrayInputStream
ByteArrayOutputStream
CharArrayReader
CharArrayWriter
DataInputStream
DataOutputStream
File
FileDescriptor
FileInputStream
FileOutputStream
FilePermission
FileReader
FileWriter
FilterInputStream
FilterOutputStream
FilterReader
FilterWriter
InputStream
InputStreamReader
LineNumberReader
ObjectInputStream
ObjectInputStream.GetField
ObjectOutputStream
ObjectOutputStream.GetField
ObjectStreamClass
ObjectStreamField
OutputStream
OutputStreamWriter
PipedInputStream
PipedOutputStream
PipedReader
PipedWriter
PrintStream
PrintWriter
PushbackInputStream
PushbackReader
RandomAccessFile
Reader
SequenceInputStream
SerializablePermission
StreamTokenizer
StringReader
StringWriter
Writer
Interfaces:
The following summary of Interfaces provided by the java.io package shown in the table:
Interface
DataInput
DataOutput
Externalizable
FileFilter
FilenameFilter
ObjectInput
ObjectInputValidation
ObjectOutput
ObjectStreamConstants
Serializable
Exceptions Classes:
EOFException
FileNotFoundException
InterruptedIOException
InvalidClassException
InvalidObjectException
IOException
NotActiveException
NotSerializableException
ObjectStreamException
OptionalDataException
StreamCorruptedException
SyncFaieldException
UnsupportedEncodingException
UTFDataFormatException
WriteAbortedException
Description
It used for creating an internal buffer array. It
supports the mark and reset methods.
This class used for writes byte to output stream. It
implements a buffered output stream.
This class provides read text from character input
stream and buffering characters. It also reads
characters, arrays and lines.
This class provides write text from character output
stream and buffering characters. It also writes
characters, arrays and lines.
It contains the internal buffer and read data from the
stream.
This class used for data is written into byte array. This
is implement in output stream class.
It used for char input stream and implements a
character buffer.
This class also implements a character buffer and it
uses an writer.
This class reads the primitive data types from the
input stream in a machine format.
This class writes the primitive data types from the
output stream in machine format.
This class shows a file and directory pathnames.
This class uses for create a FileInputStream and
FileOutputStream.
It contains the input byte from a file and implements
an input stream.
It uses for writing data to a file and also implements
an output stream.
Description
It provides detail message in the catch block to
associated with the CharConversionException
This exception indicates the end of file. When the file
input stream to be end then EOFException to be
occuted.
When the open file's pathname does not find then
this exception to be occured.
When the I/O operations to interrupted from any
causes then it becomes.
Any problems to be created with class, when the
Serializing runtime to be detected.