Discussion:
[問題] 比較C語言與Java
(时间太久无法回复)
Begins
2006-11-15 07:57:19 UTC
Permalink
不知道po在這裡合不合適...

小弟其實只懂得C語言

以下四句話, 我不知道哪些是對的哪些是錯的...

可以請眾版友位我解答嗎? 謝謝

1. C passes parameters in registers while Java passes them on the stack.

2. Strings are just an informal name for single-dimention arrays of characters
in C and Java.

3. Strings in C and Java use null(0) to mark the end of a string.

4. Operations on strings, like length, are faster in C than in Java.

--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.141.178
涼宮春日症候群
2006-11-15 08:09:58 UTC
Permalink
�� �ޭz�mJohnBintan (Begins)�n���ʨ��G
: �����Dpo�b�o�̦X���X�A...
: �p�̨����u��oC�y��
: �H�U�|�y��, �ڤ����D���ǬO�諸���ǬO����...
: �i�H�в����ͦ��ڸѵ���? ����
: 1. C passes parameters in registers while Java passes them on the stack.
C���ܬ�calling convention

�{�b��VC�u��fastcall�|���e���ӰѼƥ��iregister

�@�몺cdecl�P�ˬO��istack��

���L��compiler�N���M���F

Java���� �]�����Obytecode ���Omachine code

��ı�o(�J�M���w�g�O�ۦ��@�檺bytecode�F)��ӬO�|��istack��

(�]�N�O���|��calling convention �@�߱�istack)

(�HC�����k�Ӭ� Java���禡�I�s���Othiscall)

: 2. Strings are just an informal name for single-dimention arrays of characters
: in C and Java.
for C, yes

for Java(and C++), �ݹ��@ �]�����O�@��class, �O�]�_�Ӫ�

: 3. Strings in C and Java use null(0) to mark the end of a string.
for C, yes

for Java, �@�ˬO�ݹ��@

: 4. Operations on strings, like length, are faster in C than in Java.
�p�G�r���O��Basic�̪��r�������ץt�~������ ���b���r�������׮ɬO�|�y��

C�Ozero-terminated �ҥH�n�����״N�n�@�Ӥ@�Ӻ�

�ҥH�򥻤WC���G�ä��|������...

--
���G��Java�����׳��O�n�h�ݹ��@...XD

�ϥ��w�g���]�n���F���N���ӥΤF�� �ٺޥ��̭��O�����s�� (�ӤH�Q�k)

--
�Ե^�G�u�e���I�A�u���N�o�˳Q���輤�����l�޹L�h�F��?!�v
���G�u�u�n���ۤk���\�X�ˤ���ˤl�A�Ҧ����n���O�N�����K�A���G�@�I�����a�ڡC�v
�Ե^�G�u���D�A�S���k�H���L�Y�F��?!�v
���G(�_�M�D)�u�S���C�b�`���Y���B�ͬ��Y�����ǥ����e�A�S�����تF���C�v
�С�������Ƿǵȸ������Ƿǵ �ĤG��

--
�� �o�H��: ���������~�{(ptt.cc)
�� From: 192.192.197.115
Believing is seeing! ^^
2006-11-15 09:55:36 UTC
Permalink
※ 引述《LPH66 (涼宮春日症候群)》之銘言:
: ※ 引述《JohnBintan (Begins)》之銘言:
: : 2. Strings are just an informal name for single-dimention arrays of characters
: : in C and Java.
: for C, yes
: for Java(and C++), 看實作 因為那是一個class, 是包起來的

  也許是對題目的解讀不同,
  個人認為 Java 中的字串再怎麼包也不會只是單純的 char array,
  它至少還要有其他的 behavior 啊!?
  而且題目有強調 "just an informal name."

--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.175.161.99

继续阅读narkive:
Loading...