java vs c# struct
来源:互联网 发布:李宇春用什么音乐软件 编辑:程序博客网 时间:2024/05/17 16:54
struct
Java doesn't have struct.You may design a final class or a simple classto replace struct class Point{ public int x, y; public Point(int x, int y) { this.x = x; this.y = y; }}Point a = new Point(10, 10);Point b = a;a.x = 100;System.out.println(b.x);prints: 100Since Point is a reference type,b and a point to the same address,when a's value changed, b's value changed too.
A struct is a user-defined value type. It is declared in a very similar way to a class, except that it can't inherit from any class, nor can any class inherit from it.struct is not a reference type.struct Point{ public int x, y; public Point(int x, int y) { this.x = x; this.y = y; }}Point a = new Point(10, 10);Point b = a;a.x = 100;System.Console.WriteLine(b.x);prints: 10Since struct Point is a value type, not a reference type, a's value changeddoesn't involve b's value.
structs are sealed, lightweighted and more efficient than classes."Sealed" means they cannot be derived from or have any base class other thanSystem.ValueType, which is derived from Object.
get more about java vs C#:
1: http://www.javacamp.org/javavscsharp/
2: http://www.harding.edu/fmccown/java_csharp_comparison.html
- java vs c# struct
- C# VS JAVA
- C# VS Java
- JavaSE:JAVA VS C#
- Java vs C#
- Java vs. C#
- JAVA vs C#
- C# VS Java
- Java VS C#
- Java vs. C# delegate
- C# vs Java
- C# vs java
- C# vs C++ vs Java性能对比
- C# vs Java:北乔峰 vs 南慕容
- c# struct
- 浅谈C# vs Java (1)
- C#语言 vs java语言
- 也谈谈Java vs C#
- 键盘事件的各种属性
- SWT事件模型概述与事件处理的常用写法
- HttpMoudle and HttpHandler
- edit控件消息大全
- 编写函数时应注意的几点问题
- java vs c# struct
- 从OCX谈起 NE文件 PE文件 16位 32位
- 项目管理就是整合业务链
- 超链接传参的中文乱码解决方案
- Makefile学习教程: 跟我一起写 Makefile
- Makefile学习教程: 跟我一起写 Makefile
- 26个美国人日常生活用语
- 空调是现代病的根源--李可
- 页面关闭时结束Session