c#转 java学习笔记(原创)

JDK开发人员用,JRE运行时环境(比如给客户安装,客户电脑需要装JRE)

当我们调用构造方法的时候系统会执行如下操作:1.给对象的属性分配空间,并且初始值 0 or null 2.给属性赋缺省值  3.调用构造方法,给属性重新赋值

1、大小写区分

2、命名规范

3、关键字

 

4、数据类型

 

 

 

浮点型在小数里面寸值是不精确的,只能寸很相似的数及近似值

float与double的区别

double 有效位是15-16位,如果超过这个范围,最后一位是随机给的

double e=123.45678900000006  //这是17位,但结果最后以为可能是123.4567890000001、123.4567890000009、123.456789

布尔类型

 

字符类型

数据类型转换-默认转换(大给小)

 

数据类型转换-强制转换(小给大)

 

 数据类型转换-大小容量数据混合运算

 

整形和整形运算,结果就是整形,不用强转如下图:

数字格式化

 

 枚举类型enum(规范要求大写)

 

面向对象-内存 机制

对象会在堆里面分配

不属于对象的基本类型和引用类型都在栈里面分配

 引用类型例子

 

 this关键字

以下程序运行时间,内存是怎么分配的,如下图:

 

1、this是什么?

 this是一个引用类型,在堆中的每个java对象上都有this,this保存内存地址指向自身。

2、this能用在那些地方?

 第一:this可以用在成员方法中。

第二:this可以用在构造方法中。

this不能在静态static方法中使用 

 

 static关键字讲解

 static在类加载的时候就执行,自上而下执行,并且只会执行一次,再次实例化类也不会执行。

实例语句块(构造方法调用之前执行)

 

 数组

 数组是引用类型

 

关联关系和聚合关系

 

(下面的例子意思就是,Student可以不在这个教室,如果教室不在了,学生还在,如果学生不在了,教室还在,两个互不影响)

 

流(重点16个流)

什么是流,如下图

 

 

线程

开一个新线程,可以理解为新开一个栈桢

第一种创建线程方法(继承Thread):

 

 

java中实现线程的第二种方式

 

 线程优先级

 线程阻塞

 

 

线程的同步(重要)

第一种方式

原理如下

 

第二种方式(锁整个方法)

 

 守护线程

 

 

Timer

 

重写(不需要overrived,c#需求,java不需要)

 

 

多态

 

多态的好处(降低耦合度),多态就是:父类型引用指向子类型对象

 

 

接口的使用(接口必须有调用者和实现者)

 

(顾客拿菜单点餐、某个厨师做菜的过程)菜单就是所谓的接口,随便换厨师都可以。

 

 

 

异常处理

另外一种异常机制:如下

 

另外一种情况,下面两个图片是一个方法

另外个知识点

 

 自定义异常

 

转载于:https://www.cnblogs.com/suanshun/p/6638871.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一个很强大的工具, 能将c#代码片段、文件甚至工程直接换成java代码,并能彻底解决外部引用的DLL问题,最强的是支持c#工程的直接换,生成的Java代码质量也很不错。软件已破解,去除了未注册版最多只能换1000行的限制,亲测可用!压缩包内含帮助文档,不过由于软件的使用很简单,帮助文档基本可以忽略。(小提示:如无法运行,请确认是否安装了.NET framework) 下面是一些英文介绍: C# to Java Converter features include: 1. Folder conversion: Entire folders of C# code files are converted to Java code files.(文件夹换) 2. Code snippet and file conversion: Our snippet conversion accuracy is outstanding and does not require you to insert entire methods or classes. Heuristics are used to convert code fragments wit h missing declarations. (代码片段和文件换) 3. Full support for the latest .NET code syntax: Generics and other newer C# features are converted where possible to the Java equivalent.(全面支持最新版的.NET语法) 4. Conversion options: You can specify numerous conversion options via our Options dialog. Code formatting options, custom type & member replacements, custom string replacements, and miscellaneous options. (可以指定换规则) 5. File comparison feature: After converting a project or folder, you can compare original and converted files side-by-side. Comparing converted code to original code.(原代码与换后代码的比较) 6. Running from the command line: C# to Java Converter can be launched directly for a specific project, folder, or file conversion from the command line. Command line.(命令行执行) 其他一些特点: 1. Converts all versions of C# code (2002, 2003, 2005, 2008, and 2010) (可以换所有版本的C#代码) 2. Evaluates all referenced assemblies and .NET projects in order to resolve external references more completely.(能彻底解决外部引用的dll类库) 3. Converts C# ref parameters using Java generics 4. Superb conversions of all types of arrays 5. Handles the numerous coding alternatives and ambiguities of C# code 6. Flawless conversion of all aspects of inheritance and interfaces 7. Allows custom replacement of strings in the final converted code 8. Accurate even with poorly formatted C# code
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值