English 中文(简体)
java的果园的目的
原标题:Purpose of char in java
  • 时间:2010-12-16 07:25:33
  •  标签:
  • java

I m seeing both char and short are two bytes each, also the following is valid:

char a =  x ;
int b =  a;
long c = a;

However when I do short d = a; I m getting an error that cannot convert from char to short. even though both are two bytes.

我可以看到的是,在你印刷时,它显示出了特性。 唯一使用果园吗?

最佳回答

在 Java,数据类型<代码>>char是一个未签名的2个星号变量,而<代码>short是用2个星号签字的。 由于这一差异,您不能将<条码>代谢/编码>改为<条码>。 a 见char/code>。 这里的外线是指已签署的借方。

这意味着,如果您将<代码>char改为short。 您必须打下<代码>char,这将引起申诉。

问题回答

果园的确是一种未签署的16项合同类型,但设计并不使用。 从概念上讲,char是一种统法协会的特性(更确切地说,是统法协会编码分集的特性,可在UTF-16中代表16个参照点),这比只是一些字眼。 你们只能用果园来撰写文字。 我认为,使其成为一种愤怒的类型,是 Java一旁的一种坏设计。 除使用特殊通用方法外,它允许在果园和ger类之间进行任何转换。 如同ool豆一样,不可能转换为 in和 back。

果园一般只用于文本,是。

果园没有签名,但时间很短。

通常,我用果园来读书,数字短。 (If) 我用短时间发言。 而是在可以再利用的时候使用。

你可能希望“预测”变量。 它这样做了:

char a =  x ;
short sVar = (short)a;
System.out.println(a);
System.out.println(sVar);

<代码>char为Unicode-character,因此必须不签名。 <代码>short与所有其他数字原始类型一样。 因此,shortchar/code> 涵盖两种不同的数值,使汇编者对转让提出抱怨。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...