軟體工程師手冊/語言詞典/Visual J++
外觀
這裡有Java 維基百科條目。
Visual J++ 是一種完整的、過程式的、面向物件的、視覺化語言。
public static void main(String args[])
{
// some functionality here
}
典型的語句以分號結尾。要將 b 賦值給 a,使用
a = b;
// this is an inline comment. Everything after the // is a comment.
塊註釋以 /* 開頭,以 */ 結尾,可以跨越多行。
/* * this is a block comment */
int x = 9; Integer y = new Integer(4);
// declaration
private return_type class_name::function_name(argument_1_type arg_1_name,
argument_2_type arg_2_name,
default_argument_type default_arg_name)
{ // implementation
// work with arg_1_name, arg_2_name, and default_arg_name
// depending on the argument types the variables are passed by
// value, reference, or are constant
// don't forget to return something of the return type
return 36;
}
作用域由大括號定義。
{ // this the beginning of a scope
// the scope is about to end
}
當且僅當 A 等於 B 時,將 C 賦值給 D,否則,將 E 賦值給 F。
if( A == B )
{
D = C;
// more code can be added here. It is used if and only if A is equal to B
}
else
{
F = E;
// more code can be added here. It is used if and only if A is not equal to B
}
或者
if( A == B )
D = C; //more lines of code are not permitted after this statement
else
F = E;
或者,可以使用 switch 語句來進行多重選擇操作。此示例將數字輸入轉換為文字。
switch( number_value )
{
case 37:
text = "thirty-seven";
break; // this line prevents the program from writing over this value with the
// following code
case 23:
text = "twenty-three";
break;
default: // this is used if none of the previous cases contain the value
text = "unknown number";
}
此程式碼從 0 到 9 計數,累加陣列中的內容。
int i = 0;
for( int index = 0; index < 10; index = index + 1 )
{
i = array[index];
}
此程式碼重複執行,直到找到數字 4。如果此程式碼超出了陣列的末尾,則可能存在問題。
int index = 0;
while( 4 != array[index] )
{
index = index + 1;
}
此程式碼在檢查之前遞增計數器,因此它從元素 1 開始。
int index = 0;
do
{
index = index + 1;
}
while( 4 != array[index] );
System.out.println( "Hello World!" );
以及向視覺化元件新增文字。
容器繼承自 Collection 類。請參見 java.util 包以瞭解特定容器,包括 Vector。
它有哪些演算法?sort 在 J++ 中起作用嗎?
垃圾回收是自動的。
程式碼通常儲存在副檔名為 .java 的檔案中。它被編譯成 Java 位元組碼,並儲存在副檔名為 .class 的檔案中。
- 這種語言與 Java 非常相似。
- 視覺化窗體佈局和元件訪問類似於其他 Microsoft Visual 開發語言。
- Java 包中的類使用大寫字母,方法則不使用。
- 所有內容都是指標。使用 clone 方法來避免對 Collection 的原始元素進行操作。
- 陣列從索引 0 開始。
- 不要混淆這兩個
= // assignment == // comparison, is equal to
通常,使用你不想要的那個會編譯,並且會產生你沒有預期的結果。
- Java 華夏公益教科書頁面
- Microsoft 支援可在 [Microsoft 開發人員網路] 頁面上獲得。
紙質參考文獻在此處