Java (一):Why Use Primitive Types In Java ?

Not everything in java is an object !

Java has a dual-type system, include Primitive Types and Object Types. Primitive types are value-based, but object types are reference-based.

There are eight primitive types predefined in Java. For each primitive type there is a corresponding wrapper class that is an object type.

Why use primitive type ?

The most important factor to consider for using primitive types in Java are performance, software performance is usually measured in terms of space and time.

space. java can use primitive types to create automatic variables (local variable 局部变量) that are not references. The variables hold the value, and it’s place on the stack(栈) so its much more efficient.

Creating an object using new isn’t very efficient because new will place objects on the heap(堆). This approach would be very costly for small and simple variables.

a single double occupy 8 bytes , a single Double occupy 24 bytes.
primitive types创建的局部变量所占的空间,方法执行完后自动被释放掉;object types所占的空间,需触发GC回收, 方才释放。

Runtime Performance
To compare the runtime performances for primitives and objects, we need an algorithm dominated by numerical calculations. For this article I have chosen matrix multiplication, and I compute the time required to multiply two 1000-by-1000 matrices. Read More...

Python (一):初学记录

挑选称手兵器

学语法、码实例

[附录]

Python排行 : http://githut.info/

 

诗词摘录《远方很远》

《远方很远》

–摘录徐喜印 《远方很远》

古老的时间挂满屋檐,宽街窄巷走成了习惯;

青石牌匾祭奠着祖先,虎头虎脑的小子说着正宗方言。

院里的枣树结满香甜,村后的小河东浅西深;

老石磨碾过了沧海桑田,左邻右舍共饮一个酒坛。

千年的祝愿融进炊烟,粗茶淡饭纯朴了血缘。

苦辣酸甜一代一代相传,土生土长的庄稼养育真诚良善。

简陋的土炕夏凉冬暖,土鸡蛋不大真能解馋。

礼尚往来就凭肺腑肝胆,天上地下高手都在民间。

远方很远,望眼欲穿;

远方很远,绕在心间。

几回回哭、几回回笑、几回回呐喊,

几回回思念泪流满面。

远方很远,望眼欲穿;

远方很近,绕在心间。

几回回来、几回回去、几回回期盼,

几回回牵手难说再见。