軟體工程師手冊/語言詞典/Visual J++
外觀
(重定向自 軟體工程師手冊/語言詞典/面向物件/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 類。有關特定容器(包括 Vector)的資訊,請參閱 java.util 包。
它有哪些演算法?排序在 J++ 中起作用嗎?
垃圾回收是自動的。
程式碼通常儲存在副檔名為 .java 的檔案中。它被編譯成 Java 位元組碼,並儲存在副檔名為 .class 的檔案中。
- 該語言與 Java 非常相似。
- 視覺化表單佈局和元件訪問類似於其他 Microsoft Visual 開發語言。
- Java 包中的類以大寫字母開頭,方法不以大寫字母開頭。
- 所有東西都是指標。使用克隆方法來避免對 Collection 的原始元素進行操作。
- 陣列從索引 0 開始。
- 不要混淆這兩個
= // assignment == // comparison, is equal to
通常,使用您不想要的那個會編譯,並且會產生您沒有預期的結果。
- Java 華夏公益教科書頁面
- Microsoft 支援在 [Microsoft 開發人員網路] 頁面上提供。
紙質參考資料在此處