【正文】
s) are used in Java. ? Particularly for read/write properties, C provides a cleaner way of handling this concept. The relationship between a get and set method is inherent in C, while has to be maintained in Java. ? It is possible to create, readonly, writeonly or readwrite properties depending on if the getter and setter are implemented or not. 3. New Concepts in C: Properties ? Java: public int getSize() { return size。 } public void setSize (int val) { size = val。 } ? C: public int Size { get {return size。 } set {size = val。 } } 3. New Concepts in C: Pointers ? Although core C is like Java in that there is no access to a pointer type that is analogous to pointer types in C and C++, it is possible to have pointer types if the C code is executing in an unsafe context. ? Pointer arithmetic can be performed in C within methods marked with the unsafe keyword. ? Example: public static unsafe void Swap(int* a, int*b) { int temp = *a。 *a = *b。 *b = temp。 } 3. New Concepts in C: Pass by Refernce ? In Java the arguments to a method are passed by value meaning that a method operates on copies of the items passed to it instead of on the actual items. ? In C, it is possible to specify that the arguments to a method actually be references. ? In Java trying to return multiple values from a method is not supported. ? The C keywords used are ref and out. ChangeMe(out s)。 Swap(ref a, ref b)。 REFERENCES: ? OOP with Microsoft and Microsoft Visual C.NET by Robin A. ReyonldsHaerle ? JAVA 2 Essentials by Cay Horstmann Websites: ? Java vs. C: Code to Code Comparison ? A Comparative Overview of C: ? C: A language alternative or just J?, ? A COMPARISON OF C TO JAVA By Dare Obasanjo ? Conversational C for Java Programmers by Raffi Krikorian