| default value of data member. |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Disappearing JVM - strange errorHello,
I'm having a very strange problem in one of my applications. This is
what's happening:
A few JVMs crash without giving any clues as to what is happening. No
error messages, no stack traces, no core dumps. Nothing. Nada. They
just disappear.
I'm running on Windows 2000 and I had the same problem using JDKs
1.3.1_07 and 1.3.1_08. Sometimes I also notice a Windows error dialog
say that the "Application log is full" but I'm not sure it is related
(because when the problem happens and the dialog is NOT there we can't
see any entries in the application log).
The application is a JBoss server process which is part of a cluster.
In the process we have a RMI application running. The nodes that crash
are the nodes where this RMI client/server is deployed. When the app
server process starts we bind the RMI server stub in to the JNDI tree
and this server object communicates with a number of different
applications.
I suspect that this could be related to RMI (distributed gc, maybe?)
or the fact that this service running within the JBoss process is
multi-threaded (relies heavily on waits and notifies). But I don't
really know. The process simply disappears.
We have deployed the RMI service in different machines to rule out the
possibility of hardware failure but the crash happened anyway.
We have a memory monitor that checks the memory usage every 30
seconds. The logs show that the memory usage should not be a problem.
It is possible, though, that we have a memory spike that takes less
than 30 seconds to show up and crash the system in such a dramatic
way.
Has anyone here ever experienced or seen anything like this?
Thanks in advance for any help.
JS
- 2
- 2
- MI5-Persecution: MI5 Waste Taxpayer Millions on Pointless Hate-Campaign (18598)I don't know what the hell this is. But he/she/it asked for a respond. I
sent a 19 MB picture of my middle toe. I hope they liked it, and I have no
message saying the message did not go through. Say they must like it. I am
working on 100 MB pictures
--
AZ
<email***@***.com> wrote in message news:email***@***.com...
>
> MI5 Persecution Update: Friday 30 April, 1999
>
> If You Intend To Reply, Please Read This
> Please.... keep your response to one page!. Faxes over a page or two will
> be deleted without being read.
>
> Somewhere between 0 and 100%
>
> The last few days there have been no clear recordable instances of
> abuse. However, while travelling on the Underground, while walking around
> near my home and going to friends homes, I am constantly troubled by
> thoughts that those people over there might be about to get at me; that
> the couple sitting in the opposite seats laughing are in fact laughing at
> me; et cetera, et cetera.
>
> A comment by a scientist to the BSE inquiry sticks in my mind. He
> described the possible scale of the epidemic as "between 0% and 100%". It
> might not be happening, it might not happen at all, to any discernable
> degree.... or it might be total. Without clear recording, which seems to
> have become impossible the last couple of weeks, there is no way of
> knowing whether the harassment really is continuing, whether we have
> entered a temporary hiatus, or whether perhaps it has perhaps stopped for
> now.
>
> But for the time being I think there arent any reasons to dicontinue these
> faxes. I only re-started them six weeks ago in response to a resumption of
> MI5 harassment; and I think I will need to be more convinced of absence of
> persecution before I discontinue my complaints.
>
> The Newscasters are still watching
>
> In the last few weeks there have been at least a couple of fairly overt
> instances of "interactive watching" by newscasters. I reported this in a
> previous "MI5 Persecution Update".
>
> These instances are really very rare compared to 1990-91, when there were
> many dozens of such occurrences. Undoubtedly the reduction is due to my
> practice of videotaping everything I see. Recently I had the opportunity
> of showing this years "happenings" (Jon Snow/Nicholas Witchell) to my
> psychiatrist, and he agreed that in both cases the newscasters were
> expressing merriment without visible cause, and that objectively it might
> be possible for my claims to be true - although of course other people
> reported similar thoughts to him, and this thinking is usually a symptom
> of illness.
>
> Read About the MI5 Persecution on the World Wide Web
>
> The March 1998 issue (number 42) of .net Magazine reviews the website
> describing it as an "excellent site". Since August 11, 1996 over 50,000
> people have browsed this website.
>
> You are encouraged to read the web pages which include
>
> a FAQ (frequently asked questions) section outlining the nature of the
> persecutors, their methods of harassment through the media, people at work
> and among the general public
>
> an evidence section, which carries audio and video clips of media and
> workplace harassment, rated according to how directly I think they refer
> to me
>
> objective descriptions of the state security agencies involved
>
> scanned texts of the complaints I have made to media and state security
> agencies involved
>
> posts which have been made to netnews over the last four years on this
> topic
>
> Keith Hill MP (Labour - Streatham), my elected representative, as ever
> refuses to help.
>
> MI5 Waste Taxpayer Millions on Pointless Hate-Campaign
>
> Recently I was talking to an independent observer about the nature and
> purpose of the perceived campaign of persecution against me. The person I
> spoke to, a highly intelligent man, said he was struck by the utter
> pointlessness of the perceived campaign against me. He also said that, if
> my theories were in fact true, many people would have to be involved, in
> the surveillance itself, and in the technical side of the delivery of
> information from my home to TV studios for example, if the "interactive
> watching" were happening as described. He voiced these thoughts without
> any prompting from me; but both I and other observers had arrived at
> pretty much the same conclusions, some years ago.
>
> I saw a team of four men at Toronto Airport in 1993
>
> To carry out the surveillance alone, full-time, would employ four or five
> men, or their equivalent in terms of man-hours. Each man would "work" an
> eight-hour shift, so you would need at least three men doing the
> surveillance, plus a connecting link / manager. An indicator that this
> estimate is correct arrived in 1993, when I was accosted by one of a group
> of four men at Toronto Airport; he said, laughing, "if he tries to run
> away well find him". Plainly these were the men who had been involved in
> the intrusive surveillance of me for the preceding three years.
>
> On other occasions, I have seen the same man on two or three occasions. On
> one such occasion, at Ottawas Civic Hospital in November 1996; he gave his
> name to the doctor as "Alan Holdsworth" or some such; my hearing is not
> very good sometimes and I am not sure of the surname, although I am sure
> "Alan" was his first name. I saw exactly the same man again in Ottawa, at
> the airport, in July 1998. Obviously, other people must be "working" with
> this person; he would not be the sole agent employed in this case.
>
> Usenet readers views on the Cost to MI5 of Running the Campaign
>
> Here's what a couple of other people on internet newsgroups / Usenet
> (uk.misc) had to say regarding the cost of running such an operation...
>
> PO: >Have some sense, grow up and smell reality. What you are talking
> about
> PO: >would take loads of planning, tens of thousands of pounds and lots of
> PO: >people involved in the planning, execution and maintenance of it. You
> PO: >must have a very high opinion of yourself to think you are worth it.
>
> and......
>
> PM: >But why? And why you? Do you realize how much it would cost to keep
> PM: >one person under continuous surveillance for five years? Think about
> PM: >all the man/hours. Say they _just_ allocated a two man team and a
> PM: >supervisor. OK., Supervisor's salary, say, #30,000 a year. Two men,
> PM: >#20,000 a year each. But they'd need to work in shifts -- so it would
> PM: >be six men at #20,000 (which with on-costs would work out at more
> like
> PM: >#30,000 to the employer.)
> PM: >
> PM: >So, we're talking #30,000 x 6. #180,000. plus say, #40,000 for the
> PM: >supervisor. #220,000. Then you've got the hardware involved. And
> PM: >any transcription that needs doing. You don't think the 'Big Boss'
> PM: >would listen to hours and hours of tapes, do you.
> PM: >
> PM: >So, all in all, you couldn't actually do the job for much less than
> PM: >a quarter million a year. Over five years. What are you doing that
> makes
> PM: >it worth the while of the state to spend over one and a quarter
> million
> PM: >on you?
>
> Those are pretty much the sort of calculations that went through my head
> once I stopped to consider what it must be costing them to run this
> operation. At the very least, a quarter million a year - and probably much
> more, given the intrusive and human-resource-intensive methods
> employed. Times nine years. Equals well over two million pounds - and
> probably much, much more.
>
> Its wasteful for someone with my skills to be unemployed
>
> The wastefulness of the MI5 campaign against me is not just that of futile
> expenditure on their side. It is also extremely wasteful for someone with
> my talents to be unemployed and on a disability pension. I am highly
> qualified in numerate disciplines, yet am unable to work, specifically
> because of the MI5 hate-campaign against me. It is a terrible waste of
> resources for a supposedly efficient economy like that of the UK to be
> squandering the talents of a skilled and capable worker.
>
> I made every effort to remain in employment for as long as I could, but
> ultimately I was defeated by MI5s employment of massive resources
> specifically targeted on my workplaces with the sole aim of seeing me
> evicted from those workplaces. You might expect this sort of behaviour
> from the Stasi or some other secret police force in a communist country
> where labour is cheap, and the governments aim on seeing its citizens
> confined; but for a supposedly free and efficient economy like Britains,
> the wastefulness resulting both directly and indirectly from the Security
> Services activities is simply criminal, and should never be allowed.
>
> The international dimension means the costs are multiplied many times
> overoer had any sense, then they have surely taken leave of them over the
> last nine years.
>
> Four years of persecution in Canada
>
> The persecution re-started within less than five minutes of my arrival in
> Canada, as documented above, and in the "frequently asked
> questions" article on the website. The words, "if he tries to run away
> well find him" spoken by one of the harassers at Toronto Airport are now
> imprinted on my mind.
>
> A year later I emigrated to Canada, intending to find a job and settle
> there, hoping that MI5s interest in me might dim with time. I did manage
> to find work there, but my hopes of avoiding Security Service interest
> were ground into dust. As detailed above, I saw the same man in November
> 1996 and July 1998, both times in Ottawa. Apart from these encounters,
> there were numerous incidents between 1994 and 1998 of harassment, of an
> identical nature and in most cases using identical words to what had
> occurred in the UK. It became quite clear to me that the permanent
> surveillance and harassment operation which MI5 had subjected me to in
> England was being continued.
>
> For a team of four or five men to be employed overseas must cost a lot
> more than if they operate in their home country. And for MI5 to continue
> the operation for a period of over four years, continuously, must cost
> many hundreds of thousands of pounds. This confirms my belief that the
> state is funding the campaign against mehat the Security Service receives
> current annual funding of #160M. Divided by 1850 staff, works out at
> #86,000. But the unit annual cost of each "watcher" must be much higher
> than this, especially given the frequently mobile and overseas nature of
> their actions of the last few years. A very conservative figure might be a
> little over #100,000 pa for each of a team of five people, or half a
> million pounds per year. For nine years, so far. So the most conservative
> estimate of the surveillance element alone is perhaps four or five million
> pounds since 1990.
>
> This guesstimate is of course theoretical - I am not privy to inside
> details of how MI5 split their funding. But to take some other examples,
> the cost of a US counter-surveillance specialist per day is USD
> 5,000. Even if the agents permanently assigned to me are not of this
> calibre - even if they employ specialists when difficult work planting
> bugs etc is encountered - their salary and support costs must still be
> very high. The individual agents are doing well for themselves as they are
> well-paid to exercise psychopathic instincts which in any sane society
> would see them in prison; but the taxpayers who must fund this terribly
> wasteful exercise are being "done" out of hundreds of thousands of pounds
> each year.
>
> It must be emphasised that the above estimates are highly
> conservative. Besides the surveillance operation, it must carry a high
> cost in man-hours to propagate covert slanders through the population; to
> setup and maintain the "interactive watching" links to TV and radio
> stations, which these organisations continue desparately to "lie and
> deny"; and to induce antipathy in co-workers which would not otherwise
> exist.
>
> Why they are wasting Millions of Pounds on a "Nobody from South London"
>
> As remarked in the prologue to this article, it is really most
> extraordinary that the Security Service spends a chunk of its budget,
> every year for nine years so far, on a meaningless campaign against a
> "nobody from South London". That they are spending such a large amount of
> money has been confirmed to me on several occasions, usually by oblique
> references to "its costing this country millions". The supposed
> "logic" behind the persecution is that MI5 wish to avoid their harassment
> of me, and the involvement of the UK media, to be made public; yet as the
> reader will appreciate that is a circular argument, "theyre doing it
> because they want to keep it secret and avoid humiliation for themselves
> and their country" begs the question, "why did they start doing it in the
> first place?", to which in truth I myself do not know the answer.
>
> Plainly MI5 with its rich budget can afford half a million pounds a year
> to waste on a "nobody from South London". Some time ago I was talking to a
> British surveillance professional on Compuserve who told me "this work
> costs a lot of money and is usally because the person I am following has
> done something (usually criminal) to warrant all this money and time being
> spent." Yet in this particular case it is plainly not the "victims
> fault" that the harassment is taking place. The hate-campaign against me
> is completely the creation of the obsessive psychologies of the MI5 agents
> who have made themselves my persecutors; it is obviously a
> "personal" campaign for them, and for years they misuse taxpayer funding
> to feed their insane, unnatural and fixated fantasies.
>
> 18598
>
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> ------->>>>>>http://www.NewsDemon.com<<<<<<------
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
- 2
- jni to optimize a java application using native mathematical librariesHi,
I've built an application, nn and simulation with a lot of
visualization , in java, now my computational needs are exceeding the
power of my system.
I usually used the observer pattern to listen to changes on the data
model, and the visualization only redraws if needed and isn't
synchronized with the numerical compuation.
However i read matrix data inside my paint methods.
Can i use jni and an optimized native library to implement the
numerical elaboration?
Doing so, will my visualization code be preserved and reused?
Will my system perform better?
I think that much of the matter is in the grain of jni interface and
data exchanged between the 2 systems.. but I've not the experience to
give you all data without a little preliminary help.
So this data are only to describe the problem in general. I'll give the
details that you tell me are needed
Thanks
- 2
- Child question + illegal start of expression errorI have a form with a question and child questions
eg q1 program - Yes/no
q2 web; desktop
q3 java; .net; #C
My form is:
Q6a: Waterproblem (yes/NO)
Q6b: Current - radiobutton (curent, 1-5 years)
Q6c: Location Home (yes/No); Garden (Yes/No); common (yes/no)
If user selects Q6a = Yes (1)
....
Q6c Home (0/1); Garden (0/1); common (0/1)
I want to check, if user selects Yes for Q6a, then they need
select 1 from Q6c.
If they don't select one choice, want to have a simple error warning.
Yes = 1 No = 0
The code shows an illegal start of expression error????
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if( page8.getWasteWaterProblem() == 1 ) ||
(getWasteWaterLocationProblemHome() == 0) ||
(getWasteWaterLocationProblemGarden() == 0) ||
(getWasteWaterLocationProblemCommonArea() ==0){
validationResultPage8.addWarning("WasteWaterProlemHome", "warning for
WasteWaterProlemHome from type 6c");
}
- 3
- Process.waitFor(): a strange behaviourI have a strange behaviour with the Process.waitFor() method under
linux mdk 10.1 and java 1.4.2.
my jar archive reacha.jar launches an external programm via
Runtime.getRuntime().exec,
as done bellow,
proc = Runtime.getRuntime().exec("rv toto.rvqe");
proc.waitFor();
where rv is a shell that lauches a command eprover as shown bellow
gess 28182 0.2 1.6 218592 12532 pts/2 S<l+ 11:03 0:00 java
-jar reacha.jar test.mch
gess 29561 0.0 0.7 7424 6044 pts/2 S<+ 11:05 0:00
/usr/bin//rv toto.rvqe
gess 29727 0.0 0.1 2880 1424 pts/2 S<+ 11:05 0:00 sh -c
eprover ....
gess 29728 99.6 3.3 27376 26300 pts/2 R<+ 11:05 3:03 eprover
...
Sometime, when the eprover command spends a lot of time, and ends after
some minutes,
the method waitFor() does not seem to catch the end of the programm
and does not stop to wait...
gess 28182 0.2 1.6 218592 12532 pts/2 S<l+ 11:03 0:00 java
-jar reacha.jar test.mch
gess 29561 0.0 0.7 7424 6044 pts/2 S<+ 11:05 0:00
/usr/bin//rv toto.rvqe
When I launch by hand the programm rv, it stops alone after the end of
the eprover as shown bellow
gess 522 0.0 0.7 7424 6044 pts/2 S<+ 12:02 0:00 rv
toto.rvqe
gess 688 0.0 0.1 2876 1420 pts/2 S<+ 12:02 0:00 sh -c
eprover ...
gess 689 99.6 2.6 21436 20340 pts/2 R<+ 12:02 1:06 eprover
...
And next no more reference to rv by the ps aux command
Thank a lot for your help.
- 4
- recommend good freeware jsp editorHi.
I asked in the javascript group, and one person sent me over here (I think).
Can someone recommend a jsp editor with at least syntax coloring..
is there such a thing as code completion?..
Thanks
Jeff Kish
- 6
- How to mandate license expiry dateHi!!!
The product which i am working on requires that it can be installed
and used for a stipulated number of days from the date of
installation. Also if its installed on one machine then uninstalling
and reinstalling it on the same takes care of counting the days from
first installation and not the latest installation. Hence system date
time check is not useful in this context. Thus like many software
evaluation copies it must work strictly on license validity periods.
Issues to be tackled are :
- Stamp the isntallation date somewhere such that it persists the
subsequent installtion and uninstallation of the software. - How to do
it?
- Check the days passed since installation. Here i must check with
the date of first installation which was stamped. - Accessing stamped
date is a problem?
- Most importantly changing the system date must not affect my
license expiry checks.
One solution which i found was to keep a registry key to store the
installation date which persists the uninstallation of the software.
But this i perceive shall involve JNI(I am not sure about it, Any
inputs would be of great help). I would prefer to avoid using JNI.
Please let me know if the problem i am facing needs more
clarification. Any inputs towards solution of this problem would be of
great help.
thanks and regards.
Amit Kapoor.
- 8
- Easy Book For Learning JavaNeed recommendations on an easy book for learning Java for someone with
only
a passing knowledge of QuickBasic.
Thanks
WDA
email***@***.com
end
- 9
- linking from one portlet to another portlet in the same pagehi,
I am running bea portal 4.0. I designed a page with two portlets. The left
portlet has some url links. When the user clicks on a link the content of
the right portlet shall be updated. So can anyone tell me if it is possible
to do that or do I have to look for a different solution.
Michael
- 10
- reading & writing in serial port from serverHello to everybody,
I've done an application that draws in a frame the trajectory of a
robot. The robot position is readed through the serial port, and
several commands are wrote through the same port to change the
direction of the robot.
The trajectory frame is managed by an applet, and the project works
good when the applet is called by a html document allocated in the
same local machine under W98 where the classes and the serial port
are.
But my intention is now that the serial port is going to be in a
server machine under Linux, and the users will connect with the frame
through internet. And these are the questions:
1.- If the same application that works in a local machine is called by
these users, will it operate with the serial port of the server or the
serial port of the user PC?
2.- With the traditional applets can the users see the trajectory in
the frame with the readed data from the server serial port and operate
through the hmtl document in order to write in the server serial port?
Thanks in advance, and I hope anybody could help me in this trouble.
Bye.
- 12
- Ussgin JUnit add ons to get the superclass
Hi, I am using J-UNIT to test my code. I have some instances where
the class heirarchy is makeing my shake my head as to how to test.
Hope I can explain this so that someone can help...
Here Goes . I have a class 'A', with a private attribute 'attrib', and a
public accessor 'getAttrib'.
Now there is another class, 'B' which is derived from 'A', however, it
also has it's own private attribute 'attrib', and a public accessor
'getAttrib'.
We have software that loads A & B from XML Files, and i am trying to
verify that they are working correctly (later on these classes will be
persisted in a database, so I want to make sure that I can save and load
them correctly).
What i am trying to do is find out what is stored in 'A's attrib.
Sort of like this :
// The XML files holds teh data for both the super class and the sub
class
// The returned object is of Class 'B'
A myA = B.loadFromXMLFile ( "FileName.xml" ) ;
// Works Great, But how do i get to the getAttrib of the A object
(super class) ?
assertEquals ( "attrib", 123, myA.getAttrib () ) ;
Now is there a way to get the attribute for the attrib of 'A' ?
Using the NetBeans debugger I can se the value for attrib= 5
is there a way to do something like the following ?
// This does not work, but is there any way to acheive the
// Same results ?
A theRealA = PrivateAccessor.getField( myA, "super" ) ; // ??
// and then
assertEquals ( "attrib", 5, theRealA.getAttrib () ) ;
Thanks in Advance !
Joe
- 12
- Useless Google Holding (was Re: Jewke Hatekass)"Luke Tulkas" <email***@***.com> wrote in message news:<email***@***.com>...
> "JTK" <email***@***.com> wrote in message
> news:p0ned.749845$email***@***.com...
>
> >> 2. I don't know if he speaks Yiddish or not. Perhaps you'd provide
> >> information either way. Moreover, speaking various languages makes people
> >> multilingual but not necessarily multinational. I speak English (well,
>
> [snip]
Way back, Google's purchase of old Usenet bulletin boards was probably
a good thing (through purchase, I believe, of Deja News). Now with
the continuing evolution of the Internet - with Blogs and associated
RSS feeds, etc. - this type of forum is becoming largely irrelevant
and should be done away with. I would like to thank all of you
nimrods posting this kind of crap on this board for opening my eyes
completely to this fact. Do you actually regard yourself so highly
that you think that people actually CARE to read your constant
blatherings on this and that nonsense?
Every now and then I return to c.l.j.a. just to see if anything of
interest has been posted - kind of like how I leaf through JDJ to see
if they've managed to write a decent article. This will hopefully be
my last visit unless I end up here by mistake or by habit. Thanks
again.
- 12
- java appletsAm having problems running java applets.
When I click on an icon on a web page that wants tot run a java applet IE
hangs.
In another instance a program I run puts out Java applets. When I try to
run up the applet I ge the message in the status bar saying "Applet xml
Player started" but all i see where the applet is on the html page is a grey
box.
Please help
lk
- 12
- Killing a Parent Frame with out killing its child FrameI wrote an application where I am trying to kill a parent frame with
out killing the child one.
I have created a frame (F1) and if I click a button on F1 I am
getting a new frame (F2). Now, if I click a button on F2, I am getting
updated F1. Its fine. But if I close F2, both F2 and F1 are closing. I
am trying to close F2 with out closing F1, but getting mistake.
Pls suggest me how I can do this.
|
| Author |
Message |
Mike

|
Posted: 2007-5-29 11:01:00 |
Top |
java-programmer, default value of data member.
Hi
I have a problem about default value of data member!
+++++++ cut here++++++
class CComputer
{
private double cpu=3.0;
private double memory=1.0;
public void set(double c)
{
if(c<0)
System.out.println("Input cpu error, cpu is default value");
else
this.cpu=c;
}
public void set_memory(double m)
{
if(m<0)
System.out.println("Input memory error, memory is default
value");
else
{
memory=m;
show_memory();
}
}
public void set(double c,double m)
{
set(c);
set_memory(m);
}
void show_cpu()
{
System.out.println("cpu="+this.cpu);
}
void show_memory()
{
System.out.println("memory="+this.memory);
}
void show_all()
{
this.show_cpu();
this.show_memory();
}
}
public class bbb
{
public static void main(String args[])
{
CComputer c1=new CComputer();
c1.set(-3.5,1.5);
c1.show_all();
c1.set(-3.5,-2.0);
c1.show_all();
c1.set(-3.5);
c1.show_all();
}
}
+++++++
The output of "c1.set(-3.5,-2.0);" shows memory=1.5.
The output of " c1.set(-3.5);" also shows memory=1.5;
Why? I thought memory should be default value, i.e. 1.0.
Thank you in advance.
Mike
|
| |
|
| |
 |
Daniel Pitts

|
Posted: 2007-5-29 12:12:00 |
Top |
java-programmer >> default value of data member.
On May 28, 8:00 pm, Mike <email***@***.com> wrote:
> Hi
>
> I have a problem about default value of data member!
>
> +++++++ cut here++++++
> class CComputer
> {
> private double cpu=3.0;
> private double memory=1.0;
>
> public void set(double c)
> {
> if(c<0)
> System.out.println("Input cpu error, cpu is default value");
> else
> this.cpu=c;
> }
> public void set_memory(double m)
> {
> if(m<0)
> System.out.println("Input memory error, memory is default
> value");
> else
> {
> memory=m;
> show_memory();
> }
> }
>
> public void set(double c,double m)
> {
> set(c);
> set_memory(m);
> }
> void show_cpu()
> {
> System.out.println("cpu="+this.cpu);
> }
> void show_memory()
> {
> System.out.println("memory="+this.memory);
> }
> void show_all()
> {
> this.show_cpu();
> this.show_memory();
> }}
>
> public class bbb
> {
> public static void main(String args[])
> {
> CComputer c1=new CComputer();
>
> c1.set(-3.5,1.5);
> c1.show_all();
> c1.set(-3.5,-2.0);
> c1.show_all();
> c1.set(-3.5);
> c1.show_all();
> }}
>
> +++++++
>
> The output of "c1.set(-3.5,-2.0);" shows memory=1.5.
> The output of " c1.set(-3.5);" also shows memory=1.5;
>
> Why? I thought memory should be default value, i.e. 1.0.
>
> Thank you in advance.
>
> Mike
You're default value only gets assigned during the construction of
your object.
your "new CComputer()" sets it to 1.0, You're first call to set(-3.5,
1.5) sets that value to 1.5, and it isn't ever reset.
|
| |
|
| |
 |
Daniel Pitts

|
Posted: 2007-5-29 12:13:00 |
Top |
java-programmer >> default value of data member.
On May 28, 8:00 pm, Mike <email***@***.com> wrote:
> Hi
>
> I have a problem about default value of data member!
>
> +++++++ cut here++++++
> class CComputer
> {
> private double cpu=3.0;
> private double memory=1.0;
>
> public void set(double c)
> {
> if(c<0)
> System.out.println("Input cpu error, cpu is default value");
> else
> this.cpu=c;
> }
> public void set_memory(double m)
> {
> if(m<0)
> System.out.println("Input memory error, memory is default
> value");
> else
> {
> memory=m;
> show_memory();
> }
> }
>
> public void set(double c,double m)
> {
> set(c);
> set_memory(m);
> }
> void show_cpu()
> {
> System.out.println("cpu="+this.cpu);
> }
> void show_memory()
> {
> System.out.println("memory="+this.memory);
> }
> void show_all()
> {
> this.show_cpu();
> this.show_memory();
> }}
>
> public class bbb
> {
> public static void main(String args[])
> {
> CComputer c1=new CComputer();
>
> c1.set(-3.5,1.5);
> c1.show_all();
> c1.set(-3.5,-2.0);
> c1.show_all();
> c1.set(-3.5);
> c1.show_all();
> }}
>
> +++++++
>
> The output of "c1.set(-3.5,-2.0);" shows memory=1.5.
> The output of " c1.set(-3.5);" also shows memory=1.5;
>
> Why? I thought memory should be default value, i.e. 1.0.
>
> Thank you in advance.
>
> Mike
You're default value only gets assigned during the construction of
your object.
your "new CComputer()" sets it to 1.0, You're first call to set(-3.5,
1.5) sets that value to 1.5, and it isn't ever reset.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- package and jar filesHi,
I am new to Java. I hope someone can give me a hint.
What is the difference between package and jar files and do you use them ?
thanks
John
- 2
- R: JTable and db connectionThere is a good example in JTable example ad www.sun.com. By the way, it is
based on the idea of copying all the records in a Vector array, and then
send all to the JTable...
IMHO this isn't a good approach, but it is a good example to understand the
JTable
Bye
Giuseppe
Liguori Ferdinando <email***@***.com> wrote in message
bhl1va$55u$email***@***.com...
>
> Could you help me to definy a trouble.
> I wish see data retring db connection in a JTable.
> Could you mailing an example.
> Thanks.
>
>
- 3
- ToolTip for Graphical ItemsHello,
I'm trying to make a tool tip pop up whenever the user does a
mouse-over on a filled rectangle that I've drawn on the screen. I have
no trouble creating the rectangle
Rectangle test = new Rectangle();
And it seems like there should be something like
test.setToolTipText("rectangle"), but as far as I can tell, there's
nothing like that. Is there some way to do this?
Thanks,
Ben
- 4
- UTF 16 (byte[]) <--> String?Hi,
is there a convenient way to convert unicode that's stored in byte array to
java String?
and vice-versa?
e.g. for a single single unicode,
the higher byte would be in byte[0],
lower byte[1]
and byte[2], byte[3] = 0. null terminated
the byte array of unicode is generated from a C program and transfered over
the network ..
looking over the String API doesn't reveal much ... or am I overlooking
something?
Thanks in advance.
- 5
- Java to C++ converterHi,
I am looking for Java to C++ converter tool. Any existing tool available?
Thanks for your help in advance.
- 6
- Reset button cannot clear fields after displaying error messagesHello
my form extends from ValidatorForm
and making use of validator.xml and validator-rules.xml,
The reset button can clear fields within form
if the submit is not pressed.
If I pressed the submit button and
error messages display on the top of the form.
And then now I click the reset button again,
fields cannot be cleared.
Why is it so?
- 7
- NoClassDefFound puzzleNoClassDefFound is my least favourite error message. This one has me
stumped. I have been very sick the last few days and my brain in not
yet fully engaged, so I hope it is something simple.
I compile this fine, but when I run it, it says class
com.mindprod.example.TestProgessFilter is not defined.
The program seems too simple to have a NoClassDefFound problem.
package com.mindprod.example;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* @author Roedy Green, Canadian Mind Products
* @version 1.0, 2007-08-03 Created with IntelliJ IDEA.
*/
public class TestProgessFilter extends FilterInputStream {
/**
* tracks how many bytes we have read so far
*/
long progress;
// -------------------------- PUBLIC INSTANCE METHODS
--------------------------
/**
* Constructor
*
* @param in input stream to progress monitor
*/
public TestProgessFilter( InputStream in )
{
super( in );
}
/**
* Reads the next byte of data from this input stream.
*/
public int read() throws IOException
{
int ret = super.read();
progress++;
reportProgress();
return ret;
}
/**
* Reads up to byte.length bytes of data from this input stream
into an
* array of bytes.
*/
public int read( byte[] b ) throws IOException
{
int ret = super.read( b );
progress += b.length;
reportProgress();
return ret;
}
/**
* Reads up to len bytes of data from this input stream into an
array of
* bytes.
*/
public int read( byte[] b, int off, int len ) throws IOException
{
int ret = super.read( b, off, len );
progress += len;
reportProgress();
return ret;
}
/**
* Skips over and discards n bytes of data from this input stream.
*
*/
public long skip( long n ) throws IOException
{
long ret = super.skip( n );
progress += n;
reportProgress();
return ret;
}
// -------------------------- OTHER METHODS
--------------------------
/**
* report the progress to the user
*/
private void reportProgress()
{
// this is a dummy routine. A real version would send an event
// to a progress meter.
System.out.println( progress );
}
// --------------------------- main() method
---------------------------
/**
* test driver
*
* @param args arg[0] is UTF-8 filename to read
*/
public static void main( String args[] )
{
try
{
// O P E N
FileInputStream fis = new FileInputStream( new File( args[
0 ] ) );
TestProgessFilter tpfis = new TestProgessFilter( fis );
InputStreamReader eisr = new InputStreamReader( tpfis,
"UTF-8" );
BufferedReader br = new BufferedReader( eisr, 400/*
buffsize */ );
// R E A D
while ( true )
{
if ( br.readLine() == null )
{
// line == null means EOF
break;
}
}
// C L O S E
br.close();
}
catch ( Exception e )
{
System.err.println( e );
e.printStackTrace( System.err );
}
}
}
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
- 8
- portal library needed ?Hi all ,
I am trying to build a portal which will consist of functions like log
in , user management and some cms stuff and will probably develop more in
the future. So I am trying to search for some portal building library. Has
anyone try one of these portal library like jetspeed, jPorta, liferay ... ?
Is it really that useful ? On what basis should I use one ? As i think the
learning curve maybe quite large that I am sure i can build faster without
it. But I am not sure if I would need it when I further develop the site.
And can anyone share some pros and cons of the library.
Thanks.
Perseus
- 9
- A strange linux command execution problem from ProcessHi All,
I am using Process class to run scripts on a Fedora Core Linux
bash shell
All of my scripts are running except tho one in which i am using diff
command.
I am using simple diff command. My script is
-------------------------------------------------------------------------------------
#/bin/sh
if [ $# -eq 0 ];
then
echo "Usage: newFile oldFile outputFile"
exit
fi
FILE1=$1
FILE2=$2
OUTPUT_FILE=$3
echo "diff -c $FILE1 $FILE2 > $OUTPUT_FILE"
#diff -c $FILE1 $FILE2 > $OUTPUT_FILE
diff -c $FILE1 $FILE2 > $OUTPUT_FILE
------------------------------------------------------------------------------------------------
And I am also consuming the error and output streams so not blocking
the process.
the process returns with exit value > 0.
It would be a great help to me. If you help me solve this problem.
-Thanks,
Ratnesh.
- 10
- How to get current jar pathHi! I'm working on an application that should run on an usb pen using
an embedded Derby DB. I need the DB to be on the USB pendrive with the
application.
Pen filesystem should look like this:
/
- application/
- application.jar
- lib/
- embeddedDB
using "user.dir" system property i get the path from where the jar has
been launched, while I need the path where the jar is. How can I do?
- 11
- How to Escape a Single Quote in Java 1.5 javax.xml.xpath.* ?Hi everybody,
How to escape a single quote in java 1.5 javax.xml.xpath XPath queries?
Eg. meta[@name='Tom Jastrzebski's question']
I have tried numerous approaches that typically work but none of them did.
Does anybody KNOW how to do it?
Thanks in advance.
Tom
- 12
- Infinite loops in hashCode() and equals()What do you think the following fragment prints?:
List l = new ArrayList();
l.add(l);
System.out.println(l.hashCode());
Trick question. The result is an infinite recursion (i.e. a stack
overflow), since the hash code for a List is calculated from the hash codes
of its members.
Likewise, the following causes an infinite recursion, since lists are
defined to be equal when they have the same members.
List l1 = new ArrayList();
List l2 = new ArrayList();
l1.add(l2);
l2.add(l1);
System.out.println(l1.equals(l2));
These cases are simple to spot, but the same situation could occur with any
cyclic graph of objects that compute hash code and/or equality based on the
values of their members. Also, equals() and hashCode() are often called
implicitly, for instance when adding an object to a HashSet or HashMap.
I don't see any way this could be addressed other than by keeping track of
which objects have already been processed by the current hashCode() or
equals() call, and there's no way to do that without changing the method
signatures, to, say, add a Set:
in Object:
public final int hashCode() {
return hashCode(new HashSet());
}
public final int hashCode(Set processed)
{
if (processed.contains(this)) {
return System.identityHashCode(this);
}
else {
processed.add(this);
return this.calculateHashCode(processed);
}
}
public int calculateHashCode(processed) {
return return System.identityHashCode(this);
}
with calculateHashCode(Set) being the method that classes can override and
hashCode(Set) the method List et al. call on their members. And that is a
pipe dream, since it isn't possible to make this sort of incompatible change
at this late date.
- 13
- I write Tic-Tac-Toe in JavaThis is the most sophisticated game known to mankind and I'm not sure
if Java is good enough for it, but I'm trying anyway.
- 14
- Ant Javadoc failure when building help.I'm getting this error when trying to compile javadoc in ant from my
buildxml:
Any ideas?
C:\umg\java\web\dbtest\WEB-INF\src\build.xml:64: Javadoc failed:
java.io.IOException: CreateProcess: javadoc.exe -d
C:\umg\java\web\dbtest\WEB-INF\doc\api -classpath
C:\umg\java\web\lib\servlet-api.jar;C:\umg\java\web\lib\struts.jar;C:\umg\ja
va\lib\umg-db.jar -sourcepath
C:\umg\java\web\dbtest\WEB-INF\src -version -author
java.com.umusic.ecrm.web.test error=2
what's error=2????
this is in my build.xml:
<!-- Build Javadoc documentation -->
<target name="javadoc"
description="Generate JavaDoc API docs">
<delete dir="./doc"/>
<mkdir dir="./doc"/>
<javadoc sourcepath="./src"
destdir="./doc/api"
packagenames="*"
author="true"
private="true"
useexternalfile="yes"
version="true"
windowtitle="${project.title} API Documentation"
doctitle="<h1>${project.title} Documentation (Version
${project.version})</h1>"
bottom="Copyright © 2003">
<classpath refid="compile.classpath"/>
</javadoc>
</target>
- 15
- Just a Great Big Scrollable LineHello,
I am a bit new to java and the java swing GUI.
I am writing a JApplet.
What I am trying to do is draw a line (say from (0, 0) to (1000, 1000)) and
have the applet supply automatic scrollbars so that the user can see the
whole line (sounds stupid - I know, but its a step in my direction).
Anyway, I tried to inherit from a JLabel, change the inherited comopnent's
paintComponent method to draw a line and put the inherited component in a
JScrollPane. However, this only resulted in a Line which was only partially
seen and no scrollbars. Moreover, I discovered that if I just add text to
my label with the setText method then I get auto scrollbars if I make the
applet smaller than the text size. This means that the setText method is
doing something that defines it's boundaries for the JScrollPane to react
to. So, my question is: How do I tell the JScrollPane that my inherited
JLabel is 1000x1000 (and not just the size of the text)?
Thanks,
Aviv.
|
|
|