Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 6 của 6
  1. #1

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    How to create const method on java

    i try to write a const method like C++ like this

    Mã:
        //total income     public double getIncome() const{        return salary+allowance;    }
    but this show me more error,
    could u help me ?
    have const method on java, haven't it ???

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Impossible ! [IMG]images/smilies/2.gif[/IMG]
    In Java language, You must take care of using classes. Try to distinguish between mutable and immutable classes. [IMG]images/smilies/2.gif[/IMG]

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    hi langman
    on Java you can use 'final' keyword and C# you can use 'readonly' keyword........let's google for detail

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi zstar
    hi langman
    on Java you can use 'final' keyword and C# you can use 'readonly' keyword........let's google for detail
    Only for primitive type, not for mutable object type !

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    @langman: You are 'Lan man'.

    Trích dẫn Gửi bởi zstar
    hi langman
    on Java you can use 'final' keyword and C# you can use 'readonly' keyword........let's google for detail
    This is not true.

    Lets check out:

    Mã:
    http://www.javamex.com/java_equivalents/const_java.shtml

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •