senooken JP Social
  • FAQ
  • Login
senooken JP Socialはsenookenの専用分散SNSです。
  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. いつも魚とトマトを買いに来る客 (momosetkn@qiitadon.com)'s status on Wednesday, 18-Jul-2018 20:42:56 JST いつも魚とトマトを買いに来る客 いつも魚とトマトを買いに来る客

    #IT用誤辞典

    【再起関数】

    再帰を使ったプログラムで、スタックオーバーフローエラーが発生するような状況下でも、
    再起(立ち直る)してそのまま何事もなかったかのように処理続行させる関数のこと。

    Javaによる再起関数の実装例

    public static void main(String... args){
    int input = 1000000000;
    System.out.println( String.format("`%s`の階乗は`%s`です", input, kaijou(input)) );
    }
    private static int kaijou(int i){
    try {
    if (i == 1)
    return i;
    return kaijou(i - 1) * i;
    }catch(StackOverflowError e){
    //エラーが起きているが、無視して立ち直る
    return 0;
    }
    }

    実行結果

    `1000000000`の階乗は`0`です

    In conversation Wednesday, 18-Jul-2018 20:42:56 JST from qiitadon.com permalink
    • ひだお初段@Qiitadon repeated this.

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

senooken JP Social is a social network, courtesy of senooken. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All senooken JP Social content and data are available under the Creative Commons Attribution 3.0 license.