java to objc_C#, Java, ObjC

In Java, types are declared in their own files. There can be only one type in a single Java source file, and the file name must be the same as the type name.

C# namespaces are mostly equivalent to Java packages. Every type is contained in a package, which is defined at the top of the source file (where the type is declared). Usually, the whole application defines a root package such as "com.mycompany.appname", and all types exist in this package or sub-packages (such as "com.mycompany.appname.subpackage"). The package definitions may also reflect the folder hierarchy in the project. However, there is no aliasing or nesting of packages.

In Java,  inheritance is done using the "extends" keyword and interface implementation is done using the "implements" keyword (for example, "class A extends B implements IC, ID")

There is no "readonly" keyword (or equivalent) in Java.

All user-defined types are reference types and only primitive types are value types. Reference types are always passed by reference and value types are always passed by value (copied). There's no equivalent to the "ref" or "out" keyword in Java.

There is no delegate concept in Java. The only way to simulate this is using reflection.

Java’s "synchronized" keyword ensures thread safety before entering a method as does the [MethodImpl(MethodImplOptions.Synchronized)] attribute in C#.

In Java, a programmer cannot implement two interfaces that declare the same method.

Java doesn’t allow static constructors. Instead, there's a static block.

In Java, there is no property construct–properties need to be defined explicitly (declaring set/get methods in the containing class).

In Java, the "protected" access modifier allows access from any other type in the same package, in addition to derived types.

In Java, all methods are virtual by default, and there are no "virtual" or "override" keywords.

In Java, a programmer cannot further restrict access to an override (over the access of the overridden member).

There are no indexers in Java.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值