Java Notes
Java Notes
1899 -19
ROOBA AHMAD
Tech inn Solutions
SOFTWARE DEVELOPMENT
01-Mar-18
1.
Intro to java
Software:Approximately 8 billion devices work on the compiler of java. For example:
Software asLike
an editor:
oven, Sublime text
Machines, Android mobiles and etc.
Link: https://www.sublimetext.com/3/
Why we learn it?
Software as compiler: xamp
Link: https://www.apachefriends.org/index.html
Java jdk 8
Compiler: JDK 8
JDK includes compiler of java (javac), library files of java, event library file of
java.
Extension: .java
RULES
1. Use a class with file name without extension with public key word.
2. Use main in only one file in the whole folder.
3. Extension of object code is .class.
String [] args: java main accepts a single argument of string type array.
Basics in java:
To print hello world: System.out.println (“Hello World”);
To run a program:
Println VS print: println: works as \n or endl. & print: work without \n.
Scanner myScanner = new Scanner (System.in); <- use for input method
nex
tint is use to convert string data into integer because compile always
returns data in the form of string.
2. Collection and swings
Input using JOptionPane:
Use library file javax.swing
ArrayList:
ArrayList is built in the library file of “java util”.
name.add (“Rehan”);
name.add (“Ali”);
name.add (“Asad”);
Arrays in java
String [] name= new String [10];
Same as C++,
2. Exception Handling
Try catch
There are some errors that are nor logical nor syntax but make
disaster during compiling known as exception errors. To prevent program
we use try catch before writing the program. Mostly we use it writing or
reading a file.to read/write a file we use library file javax.swing.
Example:
5. File writing:
This program will convert data from one file to another file.
Finally is use to execute data in both cases for condition true or false.
Line 23 please enter file name to save);
6. Classes
Works same as c++ but we use dot (.) as-> in cpp.
Public String
number;
Public String
address;
To remove:
9. Full code
Layouts:
Flow layout-> arrange automatically