first chapter :
2分钟read , corny, even if not used java also know how .
Chapter Two:
1.instanceof should not in c + + , c + + using RTTI to solve this problem , it is difficult .
2.super this reference to the parent class method is relatively simple , C + + is the parent class name in the parent class :: method ( ) to solve, a little ugly.
point code affixed to try ?
public class FatherClass {
public void print(String str)
{
System.out.println("father print:"+str);
}
}
public class SonClass extends FatherClass {
public void print(String str)
{
System.out.println("son print:"+str);
System.out.println("call father print.");
super.print(str);
}
}
public class TestSuperClass {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SonClass son = new SonClass();
son.print("Test");
}
}
3. automatic type conversion and C + + , as casually turn becomes high precision , accuracy becomes low will be lost.
4. casts only (type) this one, unlike c + + with static_cast, dynamic_cast, reinterpret_cast, and const_cast.
5. Operators and c + + what is almost exactly the same.
half an hour reading .
------ Solution ------------------------------------ --------
you will C + + , unless a class to see Haskell , others are very simple.
------ Solution ---------------------------------------- ----
with the study , basically the same as c + +
key is familiar with library
------ Solution -------------------------------- ------------
missing a very important points here :
1.Java and C + + arrays are essentially different .
Java array can be understood as a special kind of object (which is a Java usability characteristics of the decision ) . It is another object instance with the same storage location on the heap . It creates the system consumes much higher than C + + arrays, memory release problem also exists ( although this is done automatically by the Java- gc 's ) . And other objects stored on the heap consistency , Java data space is allocated dynamically , for example, so that distribution is permitted :
int n=new java.util.Scanner(System.in).nextInt();
int a[]=new int[n];
In addition , Java array name is essentially a pointer variable , which points to the memory space that can be changed :
int a[]=new int[5],b[]=new int[7];
a=b;
relative , C / C + + program was developed to efficiently , for this purpose tends to reduce the ease of use. C + + arrays are stored on the stack ( global arrays and static arrays are stored in the static area ) , and its memory allocation and release of the compiler is implemented , the system consumes less . C + + arrays only static allocation , it allocates space has been determined at compile time :
void fun(int n)
{
//int a[n]; //这句通不过编译
}
In addition , according to many C / C + + programmers to say , C + + array name is essentially a " pointer constant ." As long as it is assigned to a calm space , you can not point to another address of ( the value can not be used as the left ) :
int a[5],b[7];
//a=b; //这句通不过编译
------ Solution ------------------------------------- -------
( Continued from 15th floor )
2. most likely touch on this point in the same Java soon shoes are still unclear :
Java is not multidimensional array !
Some people may think
int [] [] a = new int [5] [7];
A is a two-dimensional array defined , not in substance . a point is the essence of an object element is an array of arrays . In accordance with the C / C + + to understand , is essentially pointer array . Therefore, it does not have the characteristics of two-dimensional array : a for each element are not necessarily of equal length , for example, this definition is entirely possible :
int a[][] = new int[5][];
for (int i = 0; i < a.length - 1; i++)
a[i] = new int[i + 1];
a[a.length - 1] = null;
------ Solution ------------------------------------- -------
can see that Refbacks tutorial over and over again , especially the input and output streams , speaking superb, I especially like
------ Solution ------ --------------------------------------
2.java multithreading there are two ways implementation , the first is derived from the Thread class , and the second is to achieve Runnable interface .
two ways you said , just thread running tasks need to be performed , rather than multi-threaded two ways . In Java thread Thread a realization , and no two !
------ Solution ---------------------------------------- ----
POSIX threads jdk
------------------ ----------------------------------------
mutex java.util.concurrent.locks.Lock
rwlock java.util.concurrent.locks.ReadWriteLock
cond java.util.concurrent.locks.Condition
JDK 5 uses CAS native CPU instructions , on this basis, come up with a lot of multi-threaded concurrency tools, such as : counting semaphores , countdown latch cycle barrier gate , the thread switches and so on.
based on ARM, PowerPC, SPARC, x86 chips such as BSD, Linux, Solaris, Windows platforms , Java HotSpot VM 's ; CAS achieved by AT & T/x86 inline assembly instruction cmpxchg, cmpxchg8b etc. complete.
For C / C + + to achieve lock free in terms of CAS, you can use the system library, or according to different platforms use inline assembly to write their own
Windows InterlockedCompareExchange function in
Linux functions not readily available in GCC 4.1 + has built-in functions __sync_bool_compare_and_swap
Intel 's TBB library has ready-made atomic
------ Solution --------------- -----------------------------
java labeled . You can break out of multiple loops . . He said the statement block is tagged
------ Solution -------------------------------- ------------
JDK 5 and subsequent contract (java.util.concurrent) in something very complex , like java.util.concurrent.locks.AbstractQueuedSynchronizer is one of the most important and most complex one class . If you have a C / C + + multi-threaded / concurrent development experience , as well as a better understanding of the modern CPU architectures , then multithreading in Java and contracting as well as the implementation is well understood .
In Java, the most basic things in addition to outside , you just look at three things on it :
Java has three pillars , in java.util.concurrent, java.security, javax.cropty, javax.security four packages accounted for two ( multi-threading , security )
there is a network in java.net, javax.net in , Oh
mastered at 6 package and its subpackages content , then it can be said to achieve a level of Java another realm .
PS: Before I give the three pillars of Java, multi-threading, networking and security to take the code , hehe
in these three things very much, basically the core of Java .
multi-threaded (multi-threading and concurrent)
1: Keywords : volatile, sychronized
2: traditional thread API: java.lang.Thread, java.lang.Runnable, java.lang.ThreadGroup, Object # wait, Object # notify, Object # notifyAll
3: JDK 5 and contracting (java.util.concurrent) API: thread pool task executor , counting semaphores, countdown latch , concurrent collections ( concurrent Map, blocking queues, etc. ) , based on CPU CAS instruction atomic API (java.util.concurrent.atomic), lock API (java.util.concurrent.lock) and conditions of objects.
4: As a personal knowledge upgrade , you also need to understand , such as spin locks, separate lock, spin lock, write lock synchronization lock strategy and reentrant lock, the lock fairness significance. And a variety of concurrent locking algorithms , such as: Peterson lock , Bakery lock , etc., as well as modern CPU architecture
involving multiple threads and concurrency in an API in the java.lang and java.util.concurrent. * in .
network (network communication)
1: blocking TCP traffic , blocking UDP traffic , multicast
2: non-blocking TCP traffic , blocking UDP traffic
3: Client Communications API (java.net.URL, java.net.URLConnection other libraries )
involve network communication API and java.nio.channels in java.net package. This network has RMI related packages java.rmi, javax.rmi are excluded.
safety (security, cryptography and AAA)
1: Java encryption library JCA
2: Java encryption library extensions JCE
3: knowledge involving cryptography message digest , message authentication codes , symmetric encryption , asymmetric encryption, digital signatures
4: Network communication involving certificate management tool (keytool) and API (PKI, X.509 certificates )
5: SSL / TLS based secure network communication API (JSSE), including : a key database management, database management trust , blocking and non-blocking SSL SSL communication communications wait
6: Java Authentication and Authorization Service (JAAS) API
security-related things are :
java.security (JCA, JCE, digital certificates , as well as the JCE SPI)
javax.net (SSL / TLS)
javax.security (JAAS)
javax.crypto ( cryptography )
keytool of JDK tools
------ For reference only -------------------------- -------------
Chapter III :
1.break can jump block , c + + does not block. Block is defined as a statement before the braces and colons ;
other and c + + is basically the same, five minutes reading .
------ For reference only ---------------------------------- -----
even also learn Java, support
------ For reference only ------------------------ ---------------
this ......
"C + + does not block " ? Next how first heard this feeling ......
------ For reference only ------------------------- --------------
If I remember correctly , break and continue with the loop should be related to the concept of ... well the landlord of the block definition in question ...
------ For reference only - -------------------------------------
Chapter 4:
1.java array bounds exception will be thrown at runtime , c + + does not , declare the array method is also somewhat inconsistent .
java all the way to declare an array
int [] a = new int [4];
int a [] = new int [4];
int [] a = {1, 15, 26};
int a [] = {1, 15, 26};
2.java array is an object that comes with the length property , simple to use . c + + arrays do not own methods and properties , to know the length of the array can only sizeof (arrayObject) / sizeof (int). Of course, if you use the STL vector and the like and also as simple java .
3.java called array assignment ( or called array copying ) is actually a c + + in the two array pointer assignment , java no pointer , so the author spent a lot of saliva. Fortunately, there is java garbage collection , or else a pointer to memory even leaked . As for the real contents of the array assignment is to use System.arraycopy (ir, srcPos, ir, destPos, length); while C + + and other general use memcpy function . If you use the STL vector, then the vector to see how to write the copy constructor , assignment should be a vector object pointer refers to the past rather than the past .
4. relive the bubble sort ( time complexity O (n2)), and quick sort ( worst case time complexity is O (n2), best-case time complexity is O (nlog2n) ) .
5.For-Each java syntax was introduced , and in many places it is really simple to use . Python and has long supported c # , c + + , although the STL algorithm package introduced for_each, but due to the need to use a function pointer or slightly cumbersome.
this chapter with a lot , saw more than one hour ah !
------ For reference only ---------------------------------- -----
even also learn Java
------ For reference only -------------------------- -------------
have a foundation soon ! Pure simply takes a different syntax .
------ For reference only ---------------------------------- -----
Chapter Five: classes and Objects
1.Java the method of overloading and c + + , are distinguished through different parameters . However, c + + , you can set the default parameters, and java can not.
2.java only new objects in the most out of , or clone it out or reflected , but not directly on the stack defines it. And c + + object on the stack and heap are created a lot .
3. basic types of parameter passing , java and c + + are passed by value . Object parameter passing , java is pass by reference , c + + is a copy , which is the return value. In fact, most of the time in c + + is passed by reference or pass pointer, but java no pointer , no copy selected time-consuming and space , only to pass references .
this chapter for c + + programmers too simple , a few minutes before you start it.
------ For reference only ---------------------------------- -----
------ For reference only ---------------------------------- -----
Chapter VI : Inheritance
1. methods are overridden , if you want to call the parent class method , c + + must use the parent class name :: method name , and java with super. method name.
2. polymorphism and dynamic binding , java and c + + is almost the same, very simple.
3.final Keyword : java final keyword can speak in a class can not be inherited restricted to the same well sealed keyword in C # . And c + + do not have this stuff .
4.java abstract classes and c + + is almost the same.
5.java is the only root language , the introduction of the Object class , and its clone method like c + + in the copy constructor, it equals method is used to compare the contents , and toString method is the object as a string output .
this chapter for c + + programmers is equally simple , a few minutes before you start it.
------ For reference only ---------------------------------- -----
Chapter 7: Interface
1.java have interfaces. C + + is not only similar to that containing pure virtual function virtual class ( no pure virtual base class this argument ) . However, COM, CORBA IDL language other middleware has ( Interface Definition Language ) , the use of these middleware c + + programmers write interface and no less .
2. interfaces implemented some of the provisions :
1) If you are not an abstract class implements an interface , you must implement all the methods of its interface can be instantiated ;
2) interface all methods default to public;
3. interfaces can be used to implement polymorphism ;
4.java internal classes and c + + almost no one cares about , too lazy to think up names when used with that anonymous inner classes ( such as what the UI response function ) .
5.java object cloning , blowing a bunch is a c + + in the copy constructor . What the so-called " shallow clone , deep clone " The problem is that c + + class in the copy constructor is defined pointer encounter problems . C + + programmers a look that is known .
Interface inheritance mechanism is to maintain the single comes out and spend half an hour to see is still worthwhile.
------ For reference only ---------------------------------- -----
Chapter 8: object-Oriented Programming
C + + programmers do not look .
------ For reference only ---------------------------------- -----
is this java array is allocated on the heap ?
int[] a = {1, 15, 26};
------ For reference only ---------------------------------- -----
forget all the java objects are allocated on the heap , so:
array is not an array , anyway, is a pointer , or a reference to an object instance .
Summary : java stack without objects, arrays are all new out of a multidimensional array is an array of pointers .
understood just fine !
------ For reference only -------------------------------------- -
looked a long JAVA, recently did not empty. .
------ For reference only -------------------------------------- -
landlord , there is a second book did not write it
------ For reference only ------------------------ ---------------
not finished the weekend free to write .
what are the threads , awt, swing, feeling authors write very rubbish ah !
------ For reference only ---------------------------------- -----
有空去看看.
authors now have the ability to not want to write , too little money ;
willing to write a lack of capacity, or expressive enough.
So, China 's technical books mess , depressed.
------ For reference only ---------------------------------- -----
[Quote = quote the 23rd floor Re: ]
有空去看看.
authors now have the ability to not want to write , too little money ;
willing to write a lack of capacity, or expressive enough.
So, China 's technical books mess , depressed.
say good
------ For reference only ------------------------------ ---------
feel the need to spend time
------ For reference only ------------------------------ ---------
Chapter 9: exception Handling
1.java exception handling in the finally block , and c + + does not , so the programmer should think of a way to handle an exception occurs , such as " resource release " type of problem ;
------ For reference only ---------------------------------- -----
Chapter 10: thread
1.java language comes threading mechanism , c + + is still without threading mechanism . Although the boost :: thread library is also used by many c + + programmers widely used. But the most used under windows or windows SDK comes with thread function ; while under linux the most used or pthread. There are also some claims to support multiple platforms multithreading library .
2.java multithreading , there are two ways, first is derived from the Thread class , and the second is to achieve Runnable interface .
3.java thread is divided into four states : new, runnable, non runnable and done, this and other similar threads library ;
4.run, start, stop, sleep, suspend, resume, yield, wait, notify and notifyall methods such as the meaning is also consistent with other threads library . However, suspend, resume and stop such method is not recommended , as it may cause a deadlock .
5.java join method can be used to wait for the end of the thread , and the thread library, join in some ways is often unavailable .
6.java use synchonized keyword mutex implementation, which is very similar to the boost.thread the lock (mutex), except that it is implicit lock locking thread object . In fact, this is not conducive to the novice to understand. It also describes some of the mess synchonized usage, I believe this is only counterproductive for the novice .
this chapter for threads, introduced comparatively plain , simple multithreaded should be no problem , but a little more complicated , perhaps you need other development package . Java threads are not even a Mutex class , this is the most surprised me , just use synchonized to achieve synchronization , mutual exclusion , semaphores that much trouble ah , maybe I did not understand java multithreaded bar.
------ For reference only ---------------------------------- -----
Chapter 11: graphics Programming
1.IDE era , GUI or draw come. Layout classes in Java will need to look at most of the other Layout classes also make up the numbers , there is no one available.
------ For reference only ---------------------------------- -----
good , java multi-line it is not familiar with ah.
------ For reference only ---------------------------------- -----
java multi-line it is not familiar with ah.
------ For reference only -------------------------------------- -
support one . . The country. That's it. . Cattle were either not write a book. Either write little . . But they are classic.
the other can not agree . .
------ For reference only -------------------------------------- -
above these are my finishing in recent years for the reference
------ For reference only --------------------- ------------------
These are dry ah ...
good stuff , thank you sharing
------ For reference only ---------------------------- -----------
good stuff , thank you sharing
------ For reference only ------------------ ---------------------
very grateful ah , some of which used in c + + , and some never used .
------ For reference only ---------------------------------- -----
Chapter 12: event Handling
casual look can be understood , the novice can try to write code, the veteran can add events directly in the IDE .
Chapter XIII : Swing user interface design
with Chapter XI , casual look can be. Interface generally there is someone out , ordinary programmers can read on the line.
Summary : "java from entry to the proficient," This book is the overall quality is acceptable , c + + skilled can read about one to two days , about 80% mastery . After reading to have some basic concepts, you can write some basic procedures . After reading from the entry still early , let alone mastered .
I talk about the two confused after reading the right place , the first is never mentioned java objects , constants, where the code heap , stack, and memory distribution for c + + programmers is difficult to adapt to , and may be the reason for the length ; second did not introduce garbage collection mechanism , which may be c + + programmers are more interested in it.
In short, knot stickers and scattered .
------ For reference only -------------------------------------- -
没有评论:
发表评论