Saturday, February 2, 2019

Hello World || First java program Example -

 Hello World Example



we will learn how to write the simple program of java. We can write a simple hello java program easily after installing the JDK.

To create a simple java program, you need to create a class that contains the main method. Let's understand the requirement first.

For executing any java program, you need to
  • Install the JDK if you don't have installed it, download the JDK and install it.
  • Set path of the jdk/bin directory. 
  • Create the java program
  • Compile and run the java program

Hello World Example


  1. class Simplex{  
  2.     public static void main(String args[]){  
  3.      System.out.println("Hello Java world");  
  4.     }  
  5. }



Note - here class is a keyword and Simplex is a class name. public static void main is a main function of program here exection of java program starts.System.out.println method used to print output or value on the console.


For run this program save this file with class name.java 
save- Simple.java 

Compile - javac Simplex .java
Execute-  java Simplex

Friday, February 1, 2019

what is the Difference between Java & C++ -

What is the difference between Java  and C++

There are many differences and similarities between the C++ programming language and java. A list of top differences between C++ and Java are given below





1.Pointers

  • Java: Java does not support pointers, templates, pointer overloading, unions, etc. 
  • C++: C++ does support pointers, structures, unions, templates, operator overloading, or pointers arithmetic.

2. Support Destructors

  • Java: Java doesn’t support destructors; it has an automatic garbage collection system.
  • C++: It supports destructors; it gets invoked when an object is destroyed.

3. Conditional Compilation and Inclusion

  • Java: It doesn’t support conditional compilation and inclusion.
  • C++: These are the major features of C++.

4. Thread Support

  • Java: It has built-in supports threads in Java. There is a thread class in Java, inherit to create a new thread override the run method.
  • C++: C++ doesn't have built-in support for threads. It relies on third-party libraries for thread support

 5. Default Arguments

  • Java: Java does not support default arguments. There is no (::) in Java. The strategy definitions should dependably happen inside a class, so there is no requirement for scope determination there either.
  • C++: C++ supports default arguments. C++ has scope resolution (::), which utilize and characterize a strategy outside a class to get to a worldwide variable inside from the degree where a neighborhood variable additionally exists with a similar name.

6. Goto Statement

  • Java: Java doesn't support the goto statement
  • C++: C++ supports the goto statement.

7. Multiple Inheritances

  • Java: JJava doesn't support multiple inheritances through class. It can be achieved by interfaces in java.
  • C++: C++ supports different inheritance. The keyword virtual utilizes to determine ambiguities amid various legacy if there is any.

8. Exception Handling

  • Java:  Exception handling is different because there are no destructors. In Java,  try/catch must define if the function declares that it may throw an exception.
  • C++: While in C++, you may exclude the attempt/get regardless of whether the capacity throws an exemption.

9. Method Overloading and Operator Overloading

  • Java: Java has method overloading but no operator overloading. The classString does use the and++= operators to concatenate strings and expressionsString use automatic type conversion, but that’s a special built-in case.
  •    C++: C++ supports both technique over-loading and administrator over-loading.

10. Call by Value and Call by reference

  • java: Java supports call by value only. There is no call by reference in java
  • C++: C++ supports both calls by value and call by reference

 Conclusion

In this tutorial, we learned about the basic differences in C++ and Java. We explore each factor of Java and C++. Furthermore, if you have any additional questions or comments, feel free to leave a note below!


Hello World || First java program Example -

 Hello World Example we will learn how to write the simple program of java. We can write a simple hello java program easily after i...