TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Tuesday, 24 August 2021

August 24, 2021

Plotter In Computer | What Is Plotter In Computer | Types Of Plotter In Computer | Plotter In Computer Fundamental | Drum Plotter | Flatbed Plotter | Plotter In Computer In Hindi

 

Plotter In Computer

Plotter is an output device that perform the function of presenting charts, drawing designs and other type of hardcopy. The plotter is used to print high quality graphics. It is used for special wok, normal personal computer users do not use it.

      Plotter has two types and they are…
         1.   Drum Plotter
         2.  
Flatbed Plotter

           Drum Plotter

 In a drum plotter, the paper in which the design is left is placed over the   drum. The drum move back and forth for vertical motion.

 In this technique, there is no more than one primitive pen, which moves the control of the computer with drum horizontally with the drum pen. When both are move together, graph and design are formed.

download image of drum plotter in computer| download image of jpg

Fig: Drum Plotter



   Flatbed plotter

 In a flatbed plotter the paper is placed in a bed or tray in the move and stage a pen is mounted on an arm, which moves the paper up and down, left-right by the motor.

 It is dynamic the computer control the pen in the direction of x,y and prepares the paper in shape.

 

download image of flatbed plotter in computer| image of flatbed plotter in jpg

Fig: Flatbed Plotter



Tuesday, 28 April 2020

April 28, 2020

Thread Join Method In Java | Java Thread Join Multiple Threads | Thread Join Method In Hindi

                             Thread Join() method

The join() method waits for a thread to die. In other words, it causes the currently running threads to stop executing until the thread it joins with completes its task.

java thread join multiple threads

Fig: Join () Method 

Syntax:

public void join()throws InterruptedException
public void join(long milliseconds)throws InterruptedException

  

   Example of join() method 

   class TestJoinMethod1 extends Thread{  
    public void run(){  
     for(int i=1;i<=5;i++){  
    try{  
    Thread.sleep(500);  
    } 
    catch(Exception e){System.out.println(e);}  
     System.out.println(i);  
    }  
      } 

April 28, 2020

Java Garbage Collection | Java Garbage Collection Example | Java Garbage Collection Type

        Java Garbage Collection

In java, garbage means unreferenced objects.

Garbage Collection is process of reclaiming the runtime unused memory automatically. In other words, it is a way to destroy the unused objects.

To do so, we were using free() function in C language and delete() in C++. But, in java it is performed automatically. So, java provides better memory management.

example java garbage collection
Fig: Java Garbage Collection



Advantage of Garbage Collection

o    It makes java memory efficient because garbage collector removes the unreferenced objects from heap memory.
o    It is automatically done by the garbage collector(a part of JVM) so we don't need to make extra efforts.

 

How can an object be unreferenced?

example unreferenced object

Fig: Unreferenced Object 

There are many ways:
  • By nulling the reference
  • By assigning a reference to another
  • By anonymous object etc.

 

  1) By nulling a reference:

      
       Employee e=new Employee();  
       e=null;  

 

2) By assigning a reference to another: 

Employee e1=new Employee();
    Employee e2=new Employee();  
  e1=e2;//now the first object referred by e1 is available for garbage collection  

3) By anonymous object:

    new Employee();  

 

finalize() method

The finalize() method is invoked each time before the object is garbage collected. This method can be used to perform cleanup processing. This method is defined in Object class as:
     protected void finalize(){}  

gc() method

The gc() method is used to invoke the garbage collector to perform cleanup processing. The gc() is found in System and Runtime classes.
      public static void gc(){} 


Simple Example of garbage collection in java

    public class TestGarbage1{  
    public void finalize(){System.out.println("object is garbage collected");}  
    public static void main(String args[]){  
   TestGarbage1 s1=new TestGarbage1();  
   TestGarbage1 s2=new TestGarbage1();  
   s1=null;  
   s2=null;  
   System.gc();  
  }  
    }  

Output:

       object is garbage collected
       object is garbage collected

Monday, 27 April 2020

April 27, 2020

Deleting Email In Java

Deleting email in Java

As we send, forward and receive the emails, we can delete it too. The setFlag method of Message class is used to delete a particular message.

For better understanding of this example, learn the steps of sending email
 using JavaMail API first.

For receiving or sending the email using JavaMail API, you need to load
the two jar files:

o    mail.jar
o    activation.jar

download image deleting email

Fig: Deleting Email



Steps for deleting the email using JavaMail API

There are total 5 steps for deleting the email. They are:
1.    Get the session object
2.    create the store object and connect to the current host
3.    create the folder object and open it
4.    Get the message to delete
5.    delete the message using setFlag method

Example of deleting email in Java

   import com.sun.mail.imap.protocol.FLAGS;  
   import java.io.*;  
   import java.util.*;  
   import javax.mail.*;  
   import javax.mail.internet.*;  
  
  public class DeleteMail {  
  
   public static void main(String args[]) throws Exception {  
  
 String user= "dwivedicyberdairy@completejavaschool.blogspot.com";//change accordingly  
   String password="xxxxx";//change accordingly  
  
    //1) get the session object  
   Properties properties = System.getProperties();  
   Session session = Session.getDefaultInstance(properties);  
  
   //2) create the store object and connect to the current host   
   Store store = session.getStore("pop3");  
   store.connect("mail.completejavaschool.blogspot.com",user,password);  
  
   //3) create the folder object and open it  
    Folder folder = store.getFolder("inbox");  
  
   if (!folder.exists()) {  
   System.out.println("inbox not found");  
   System.exit(0);  
   }  
  
   folder.open(Folder.READ_WRITE);  
  
   //4) Get the message to delete  
   Message[] msg = folder.getMessages();  
  
    //System.out.println((messages.length+1)+" message found");  
   for (int i = 0; i < msg.length; i++) {  
   System.out.println("--------- " + (i + 1) + "------------");  
   String from = InternetAddress.toString(msg[i].getFrom());  
   
   if (from != null) {  
     System.out.println("From: " + from);  
   }  
  
   String replyTo = InternetAddress.toString(  
   msg[i].getReplyTo());  
   if (replyTo != null) {  
    System.out.println("Reply-to: " + replyTo);  
   }  
  
   String to = InternetAddress.toString(  
   msg[i].getRecipients(Message.RecipientType.TO));  
    
   if (to != null) {  
    System.out.println("To: " + to);  
   }  
  
   String subject = msg[i].getSubject();  
   if (subject != null) {  
    System.out.println("Subject: " + subject);  
   }  
   Date sent = msg[i].getSentDate();  
   if (sent != null) {  
    System.out.println("Sent: " + sent);  
   }  
   System.out.println("Message : ");  
   System.out.println(msg[i].getContent());  
  
   }//end of for loop  
  
     // get the message number to delete (optional)  
  System.out.println("Enter message number to delete :");  
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in  ));  
  String no = br.readLine();  
  //5) delete the message using setFlag method  
  msg[Integer.parseInt(no) - 1].setFlag(FLAGS.Flag.DELETED, true);  
    
  System.out.println("Message Deleted .....");  
  
  folder.close(true);  
  store.close();  
  }  
}