My view of Java (SE) and C + + (written by the university)

Source: Internet
Author: User

when I was in college, I saw it by chance and shared it with me.

University learned a lot of programming language related things, assembly, C, Objective-c, C + +, C #, HTML, Css+div, ASP, JavaScript, XML, VHDL, Java, etc., previously elective java, purely soy sauce. For the top five languages of the Tiobe programming language rankings, they have been learned. The main research direction is C + +, training in training institutions for 4 months, in the school used C # several times to set up, in the company with Objective-c for six months of development, only Java study the worst, while the University of the last time, just dorm and Java God, the evil fill.
more than a few languages, in order to stand at a certain height, see the pros and cons of various languages, the programming has a deeper understanding. Listen to others, the language does not understand, the important thing is the algorithm and ideas, only when the understanding of two or three languages, probably can understand the meaning of the words.
after learning the basic part of Java, feel with C + + no difference, less than two days time, completely able to handle, to say that there is a difference is the console input.
1 Console input is different
Java:
Import Java.util.Scanner;
Scanner in = new Scanner (system.in);
int i = In.nextint ();
String str = in.nextline ();
.....
C++:
#include <iostream>
using namespace Std;
int i;
Cin >> I;
String str;
CIN >> str;
...
began to learn Java's object-oriented parts, Java classes and C + + classes are similar, only a few subtle differences.
2 API Delivery Methods
Java:
Use Javadoc to extract the contents of a document comment (/**.....*/) in the source file, and the class must be of the public type, generating a Web page that is provided as a Web page.
These include:
File description: @author xxx (author), @version xxx (version)
Function Description: @param args xxx (incoming parameters), @return xxx (return value)
C++:
In the form of a header file

Modifiers for Class 3
Java:
Public is visible in this package and in other packages, forcing the class name to be the same as the file name and only the public class to generate the document with Javadoc
Abstract indicates that a class must be inherited before it can be used
Final cannot be inherited (you can also modify the function so that it cannot be rebuilt, modify the variable to make it a constant, equivalent to a const in C + +)
C++:
Class has no modifiers

4 Referencing files
Java:
The form of the Guide package: the folder under the src file starts
Import src folder. Subfolders 1. subfolder 2.~. class file name
C++:
#include the header file name of the folder/subfolder 1/Subfolder 2/~/class in the current folder

5 Inheritance
Java:
Only support single inheritance, through the keyword extends, there is no way to inherit the choice, but to implement multiple interfaces, using the keyword implements, the following multiple interface names separated by commas
C++:
Support multiple inheritance, inheritance can have public,protected and private, using the colon ":"

6 sub-class constructors
Java:
Call the constructor of the parent class in the subclass by calling Super (argument list)
C++:
Call the constructor of the parent class in the parameter initialization list of the subclass constructor

Default parameters for Class 7 member variables
Java:
The initial value can be assigned directly at the time of definition
C++:
Given a default value in the parameters of the constructor

8 interface
Java:
Using the interface definition, where the function must be abstract and optionally implement an interface
C++:
No interfaces, use abstract classes

9 Exception handling
Java:
Try-catch-finally
C++:
Try-catch

10 namespaces
Java:
Package class name (including path);
C++:
using namespace namespace life;

Multithreading:
Java:
Inheriting the thread class overriding the Run method, calling start to start the thread
Implement the Run method in the Runnable interface, call start to start the thread
C++:
The C + + language itself is not multi-threaded and is related to the operating system.

My view of Java (SE) and C + + (written by the university)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.