GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing www.tutorialspoint.com — Java vs C++
Selected Reading
Java vs C++Java is a general-purpose, high-level programming language. Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]). C++ is a middle-level, case-sensitive, object-oriented programming language. Bjarne Stroustrupcreated C++ at Bell Labs. C++ is a platform-independent programming language that works on Windows, Mac OS, and Linux. Read through this chapter to get an overview of C++ and Java and the features that differentiate these two popular programming languages. What is Java?The latest release of the Java Standard Edition is Java SE 23. With the advancement of Java and its widespread popularity, multiple configurations were built to suit various types of platforms. For example: J2EE for Enterprise Applications, J2ME for Mobile Applications. The new J2 versions were renamed as Java SE, Java EE, and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere. Features of JavaThe most important features of Java are listed below −
ExampleTake a look at the following simple Java program − package com.tutorialspoint;
import java.util.Scanner;
public class JavaTester {
public static void main(String args[]) {
String a, b;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter The value for variable a");
a = scanner.nextLine();
System.out.println("Enter The value for variable b");
b = scanner.nextLine();
System.out.println("The value you have entered for a is " + a);
System.out.println("The value you have entered for b is " + b);
scanner.close();
}
}
In our example, we have taken two variables "a" and "b" and assigning some value to those variables. Note that in Java, we need to declare datatype for variables explicitly, as Java is strictly typed language. As Java is an object oriented language, we use objects to perform any action. We have used the Scanner class object to read user input from console which is represented by System.in object. System.out object method println() is used to print the values received. On execution, this Java code will produce the following output − Enter The value for variable a 10 Enter The value for variable b 20 The value you have entered for a is 10 The value you have entered for b is 20 What is C++?C++ is a statically typed, compiled, multi-paradigm, general-purpose programming language with a steep learning curve. Video games, desktop apps, and embedded systems use it extensively. C++ is so compatible with C that it can build practically all C source code without any changes. Object-oriented programming makes C++ a better-structured. Features of C++Let's see some features of C++ and the reason of its popularity.
ExampleLet's understand the syntax of C++ through an example − #include <iostream>
using namespace std;
int main() {
int a, b;
cout << "Enter The value for variable a \n";
cin >> a;
cout << "Enter The value for variable b";
cin >> b;
cout << "The value of a is "<< a << "and" << b;
return 0;
}
In our example, we are taking input for two variables "a" and "b" from the user through the keyboard and displaying the data on the console. On execution, it will produce the following output − Enter The value for variable a 10 Enter The value for variable b 20 The value of a is 10 and 20 Difference between Java and C++The following table compares and contrasts the important features of C++ and Java −
ConclusionJava is independent of the operating system, which allows it to operate on any OS through the JVM. Additionally, it offers automatic memory management and built-in multithreading for safety and ease of use. It does not include complex features like pointers, which increases the security and maintainability of the code. On the other hand, the C++ provides greater flexibility with the use of pointers and manual memory management. This, in turn, increases the level of complexity. For this and other reasons, Java is the most suitable option when it comes to companies that want to develop secure, dependable, and portable software. Advertisements
| ||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |