Java Programming Tutorial – 1 – Installing the JDK
To download this you tube video, Click Here Tutorial on Installing the JDK. ...
To download this you tube video, Click Here Tutorial on Installing the JDK. ...
class Outer { //int i; public void Display() { System.out.println(”hi”); for(int i=1;i<=10;i++) { class Inner { public void MethodInner() { System.out.println(”Hello”); } } Inner a=new Inner(); a.MethodInner(); } } } public class ForRegInnerClass { public static void main(String args[]) { Outer ou=new Outer(); ou.Display(); } } A tricky for loop with inner class class Outer { //int ...
class Outer { String s=”Welcome”; public void MethodInner() { Inner in=new Inner(); in.InnerMethod(); } class Inner { public void InnerMethod() { System.out.println(”Hello!”+s); } } } class RegInnerClass { public static void main(String args[]) { Outer ou=new Outer(); ou.MethodInner(); } } Classes that are defined inside another class are called inner class or nested class. Inner classes benefits in access control and naming control. Try ...
import javax.servlet.*; import java.io.*; public class HelloServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(”text/html”); PrintWriter out = response.getWriter(); out.println(”<html><head><title>Hello!</title></head>”); out.println(”<body bgcolor=\”white\”><h1>Hello Servlet World</h1>”); out.println(”</body></html>”); out.close(); } } Servlets are the server side programming language. Servlets are loaded by the container which instantiates the init() followed by the service() method. Destory() method is called to take ...
Consider a multi-threaded environment in which a thread access write and read of a same resource thread, java gives wrong output. Consider a scenario in which java access a resource in which one thread does the read operation and write thread does the write operation then file will be corrupted, locking the access is necessary to ...
Java Annotation offers a feature to suppress warnings that occurs during compile time. Basically there are seven level of suppressions that can be added to the java class They are as follows: all finally serial path fallthrough unchecked deprecation Find below the deprecation suppress warning example import java.util.Date; public class SuppressWarningsExample { //@SuppressWarnings(value=(”deprecation”)) public static void main(String args[]) { Date date = new Date(2008,9,30); System.out.println(”date = ” ...
Java offers a static ArrayCopy method from System class: java.lang.System.arraycopy() method offers a convenient method to copy array elements from one array to another. System.arraycopy(Object source_array, int source_position, Object destination_array, int destination_position, number_of_elements) System.arraycopy() takes five parameters. First parameter specifies the source_array from where the elements need to be copied. Second parameter is the position(index) value of the source array ...
public class OverrideAnnotation { public static void main(String s[]) { OverrideExample e = new OverrideExample(); System.out.println(e.toString()); } } Annotations are kind of meta data which can be used in java classes. Typically methods, variables, classes and packages can be annotated. Annotations basically provides information to the java compilers. Annotations can able to used to generate XMLs. Try out the below ...
ScriptEngineManager implements ScriptEngine classes. ScriptEngineManager holds key and value pair and stores the state of an object which is shared the engines created by the Manager. ScriptEngineManager uses the service provider technique to itemize implementations of ScriptEngineFactory. Binding between the key and value pairs are traditionally referred to as the “Global Scope” that is available to ...
import java.io.*; class FileEx { public static void main(String [] s) throws IOException { // File f = new File(”xyz.txt”); // f.delete(); File f1 = new File(s[0]); f1.mkdir(); File f2 = new File (f1,s[1]); f2.mkdir(); File f3 = new File (f2,s[2]); f3.mkdir(); if(f3.mkdir()) { System.out.println(”Folder Created….”); File ff = new File(f3,”akshatha.txt”); ff.createNewFile(); } else { System.out.println(”folder already exists…”); } ...