"함수 ucfirst()"의 두 판 사이의 차이

4번째 줄: 4번째 줄:
* "uppercase first"
* "uppercase first"
* 첫글자를 대문자로 바꾸는 함수
* 첫글자를 대문자로 바꾸는 함수
==Java==
[[분류: Java]]
{{참고|자바 ucfirst()}}
<source lang='Java'>
public class MyClass {
    static String ucfirst(String str) {
        return  str.substring(0, 1).toUpperCase() + str.substring(1);
    }
    public static void main(String args[]) {
        System.out.println( ucfirst("hello world!") ); // Hello world!
        System.out.println( ucfirst("HELLO WORLD!") ); // HELLO WORLD!
    }
}
</source>


==Perl==
==Perl==

2018년 8월 19일 (일) 02:06 판

1 개요

함수 ucfirst()
  • "uppercase first"
  • 첫글자를 대문자로 바꾸는 함수

2 Java

public class MyClass {
    static String ucfirst(String str) {
        return  str.substring(0, 1).toUpperCase() + str.substring(1);
    }
    public static void main(String args[]) {
        System.out.println( ucfirst("hello world!") ); // Hello world!
        System.out.println( ucfirst("HELLO WORLD!") ); // HELLO WORLD!
    }
}

3 Perl

print ucfirst('hello world!');
# Hello world!

4 PHP

<?php
echo ucfirst( 'hello world!' );
# Hello world!
echo ucfirst( 'HELLO WORLD!' );
# HELLO WORLD!

5 Python

s = 'hello world!'
print ( s[0].upper() + s[1:] )
# Hello world!
s = 'HELLO WORLD!'
print ( s[0].upper() + s[1:] )
# HELLO WORLD!

6 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}