僕はプログラマみたい
こんばんは。 簡単な関数について書くようにします。
Hello. I will try to write about a simple function.
これは簡単な関数です。 関数の後、説明します。
Here's the simple function. After the function, I will explain.
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
public boolean validateString(String str)
{
//First check for null or empty string
if (str == null || str.length() == 0)
return false;
for (int i = 0; i < str.length(); i++)
{
//Check for non-digit characters.
if (!Character.isDigit(str.charAt(i)))
return false;
}
return true;
}
ーーーーーーーーーーーーーーーーーーーーーーーーーー
関数名は「validateString」です。 この関数の返却値はブール値で、関数の引数はストリングです。 ストリングの変数は0点かヌルちがあれば、偽を復帰します。 ストリングの文字配列は字を含有したら、偽も復帰します。 でも、それがそうでなければ、真を復帰します。
The name of this function is validateString. This function's return value is a boolean, and it's argument is a string. If the string variable is zero or null, false is returned. If the string of characters contain a letter, false is also returned. But, if this is not the case, true is returned.
This function validates a string to make sure it contains only numbers, so it can turn the string into an integer safely.
Hello. I will try to write about a simple function.
これは簡単な関数です。 関数の後、説明します。
Here's the simple function. After the function, I will explain.
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
public boolean validateString(String str)
{
//First check for null or empty string
if (str == null || str.length() == 0)
return false;
for (int i = 0; i < str.length(); i++)
{
//Check for non-digit characters.
if (!Character.isDigit(str.charAt(i)))
return false;
}
return true;
}
ーーーーーーーーーーーーーーーーーーーーーーーーーー
関数名は「validateString」です。 この関数の返却値はブール値で、関数の引数はストリングです。 ストリングの変数は0点かヌルちがあれば、偽を復帰します。 ストリングの文字配列は字を含有したら、偽も復帰します。 でも、それがそうでなければ、真を復帰します。
The name of this function is validateString. This function's return value is a boolean, and it's argument is a string. If the string variable is zero or null, false is returned. If the string of characters contain a letter, false is also returned. But, if this is not the case, true is returned.
This function validates a string to make sure it contains only numbers, so it can turn the string into an integer safely.
- 49
- 2
- 4
Journals Statistics
| Total | 139 entries |
|---|---|
| This Month | 0 entries |
| This week | 0 enrties |
Latest entry
| 手紙 (4) |
| 来学期 (5) |
| 僕はプログラマみたい (6) |
| 「私の好きな有名人」について作文 (5) |
| 言葉とフレーズのために勉強する (4) |
Latest comments
| Apr 22nd chikka |
| Apr 15th coco |
| Apr 15th Snoopy |
| Apr 15th 掻捨太郎 |
| Dec 02nd coco |
Entries by Month
| 2010 |
|---|
| - April (1) |
| 2009 |
| - December (1) |
| - November (3) |
| - October (15) |
| - September (12) |
| - August (2) |
| - May (4) |
| - April (18) |
| - March (13) |
| - February (5) |
| - January (2) |
| 2008 |
| - December (5) |
| - November (16) |
| - October (33) |
| - September (9) |

簡単な関数について書くようにします書きます。
後ほど、説明します。
The name of this function is validateString. This function's return value is a boolean, and it's argument is a string. If the string variable is zero or null, false is returned. If the string of characters contain a letter, false is also returned. But, if this is not the case, true is returned.
関数名は「validateString」です。この関数は、文字列を引数とし、ブール値(真偽値)を返します。もし文字列がnullか若しくは長さ0であれば、falseを返します。また、もし文字列に(数字以外の)文字が含まれていれば、falseを返します。それ以外の場合は、trueを返します。
This function validates a string to make sure it contains only numbers, so it can turn the string into an integer safely.
この関数は、文字列から数値への変換を安全に行うために、文字列に数字だけが含まれているかを確かめます。
簡単な関数について書いてみます。 *「書いてみます」にtryの意味が含まってます。 「書いてみようと思います。」もいいです。
ストリングの文字配列は文字を含んでいたら、偽も復帰します。
でも、それがそうでなければ、真を復帰します。
私がVBAやSASでプログラムを組んでいた時は、英語で書かなくてはならなくて、if から始まるプログラムがたくさんありました。もうすっかり忘れちゃったけど。
簡単な関数について書くようにしいてみます。
この関数の返却値戻り値はブール値(真偽値)で、関数の引数はストリング(文字列)です。
ストリングの変数はが0点かヌルち無効値がであれば、偽を復帰返します。
ストリングの文字配列はが(数字以外の)字文字を含有したら含んでいても、偽もを復帰返します。
でも、それがそうでなければ、真を復帰返します。
I changed some technical words to more major words in Japanese.
I wanted to say "プログラムの説明を日本語で書くのは..."
Anyway, you changed your avatar, don't you?
it seems like a last boss of Dragon quest. hehe
簡単な関数のことについて書きます。
関数の内容(ソース)の後、説明します。
この関数の返値はbooleanで、関数の引数は文字列(or String)です。
文字列の変数の長さ0点かnullであれば、偽(or false)を返します。
文字列に数字以外の文字を含有していた場合も、偽(or false)を返します。(元の英文にはletter以外としか書いていませんが、ソース見るとこちらの説明のほうが良いと思います)
でも、それがそうでなければ、真(or true)を返します。
ここでは、boolean String(「文字列」も良く使われる) true/false(「真/偽」も使われる) null integer(「整数」も使われる)あたりが、英語のままのほうが良く使われていると思います。
私には英語だろうと日本語だろうと何語だろうと宇宙語みたい。。。
わからな~~~い