πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19997

Re: const in Java

#19997
From: Eric Nagler
Date: Tue, 11 Nov 1997 00:00
64 lines
1941 bytes
Well, in some cases the 'final' keyword can be used:

class X
{
  static int data;
}
public class Main
{
  public static void main(String args[])
  {
    foo(new X());
  }
  static void foo(final X ref)
  {
    ref.data = 0; // OK
    ref = new X(); // Error
  }
}

But unlike "const char* a", 'final' does not protect the
object being referrred to.


On 11 Nov 1997 18:20:23 GMT, "Steve Demuth"
<steved@artemisalliance.com> wrote:

>Brian is correct that java has not const keyword, but incorrect that you
>can't accomplish 
>
>  void a(const char* a);
>
>in java.  In fact, allowing for the difference between a char* and a String
>object,
>
>  void a(String a)
>
>does exactly that.  In java all arguments are passed by value (that is, as
>constant references, or "const p*".
>
>Steve Demuth
>Artemis Alliance
>
>
>Brian Burton <brian.burton@burton-computer.com> wrote in article
><346207B2.3651FB01@burton-computer.com>...
>> No.  Java does not have const.
>> ++Brian
>> 
>> Ferran Busquets ForοΏ½s wrote:
>> > 
>> > How can i call a method with a const parameter?
>> > 
>> > In c++ i can do this: void a(const char* a);
>> > 
>> > Can i do the same thing in java?
>> > 
>> > Thanks!
>> 
>> -- 
>> Brian Burton                        Custom Software Development
>> Burton Computer Corporation         Java, C++, Orbix, Tuxedo
>> http://www.burton-computer.com      OO Consulting and Mentoring
>> 
Technical Details
Message-ID: <346af095.24672737@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3460FE29.6E0B0E7D@partal.com> <346207B2.3651FB01@burton-computer.com> <01bceecf$1dbb8200$cb00a8c0@pentpro5>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f74b3,281638c33db843f0
X-Google-Attributes: gidf74b3,public
From: 76711.521@compuserve.com (Eric Nagler)
Subject: Re: const in Java
Date: 1997/11/11
Message-ID: <346af095.24672737@forums.borland.com>
X-Deja-AN: 288741394
References: <3460FE29.6E0B0E7D@partal.com> <346207B2.3651FB01@burton-computer.com> <01bceecf$1dbb8200$cb00a8c0@pentpro5>
Organization: TeamB
Newsgroups: borland.public.jbuilder.java.language