7,116 Posted Topics

Member Avatar for kumpul101

for (byte j = 1; j <= i; j++){ ... If i is 2, this inner loop will be executed twice (j=1 and j=2) If i is 3, this inner loop will be executed three times(j=1 and j=2 and j=3) etc

Member Avatar for JamesCherrill
0
111
Member Avatar for rje7
Member Avatar for masijade
0
125
Member Avatar for NewOrder

I know this is marked "solved", but here's some more info that may be helpful. 1. The console problem is generic to IDE's. NetBeans has it as well. It's a Java thing, as ~s.o.s~ noted. 2. You can achieve the same result easily by using a BufferedReader on System.in as …

Member Avatar for JamesCherrill
0
200
Member Avatar for ozlem.a17

Line 7 you have new Room(...), but Room isn't a class, it's an interface. You can only "new" a class such as RectangularRoom. But why aren't you adding the Room that's passed in as a parameter? And, you create a new list each tine this is called, and that goes …

Member Avatar for JamesCherrill
0
116
Member Avatar for NewOrder

I use Eclipse. If you refer to a method that is not defined Eclipse offers you a number of possible fixes. One of those is to create a method in the appropriate class with the appropriate signature. Used with a little forethought this can save a whole heap of typing, …

Member Avatar for NormR1
0
200
Member Avatar for Pushpasheela

The data for a JTable is held in its TableModel. To add a row, you add it to the TableModel, eg [url]http://www.exampledepot.com/egs/javax.swing.table/AppendRow.html[/url]

Member Avatar for JamesCherrill
0
94
Member Avatar for TheComputerGuy

Presumably you are not passing any args to the main method. In Eclipse you can do this in the Run Configurations dialog, in the tab labelled (x)= Arguments

Member Avatar for NormR1
0
108
Member Avatar for daudiam

A member can't be both static and instance. I think there may be confusion between references and objects here. In masijade's example one is a reference variable. It is static. new Integer(1) is an object. It's an instance of the Integer class. Instance variables are not the same as instances …

Member Avatar for daudiam
0
364
Member Avatar for daudiam

[QUOTE]it is impossible to define a local (§14.3) enum, or to define an enum in an inner class (§8.1.3).[/QUOTE] Java Language Reference version 1.6 section 8.9

Member Avatar for daudiam
0
80
Member Avatar for daudiam

Are you using jmf, quicktime, or what? Each of these have methods to return all the characteristics of a movie.

Member Avatar for daudiam
0
117
Member Avatar for glenak

[QUOTE]Also, how do I get my to run my client on a different machine and connect to my own machine? I tried connecting my client to my public ip (cos my server's in my machine), but it wouldn't connect. [/QUOTE] "localhost" 127.0.0.1 usually works, public IP is likely to be …

Member Avatar for glenak
0
184
Member Avatar for phouse512

[QUOTE]Hello, I've looked all over for the solution to this problem, but they all present a similar solution to this one and they all don't work.[/QUOTE] Well, actually, they do, which is why you see it described so often. It's not the solution that doesn't work, it's your implementation of …

Member Avatar for phouse512
0
77
Member Avatar for ozlem.a17

I assume that's part of a method? You declare the ArrayList within the method, so it will vanish each tine the method terminates. You also initialize it to a new (ie empty) ArrayList every time. It needs to be declared and initialized somewhere outside the method.

Member Avatar for NormR1
0
142
Member Avatar for Garee

+1 for the above. This was a debate that was settled in the industry in the 1960's. Call it modularisation, delegation, encapsulation, whatever. It's best to break code into small understandable units, and in Java that means classes & methods.

Member Avatar for JamesCherrill
0
85
Member Avatar for Dupron

[QUOTE]it is not giving desired result.[/QUOTE] Come on now, what is that telling us? Describe [I][B]exactly [/B][/I]what is going wrong - what [B][I]exactly [/I][/B]did you expect and what [B][I]exactly [/I][/B]did you get?

Member Avatar for yasuodancez
0
571
Member Avatar for supra

If you have JDK 6 installed (and if you haven't, do it now!) then you already have a pretty neat, useful, free, 100% supported database installed and ready to go. JavaDB (based on Apache Darby) is part of a standard JDK6 install. It's very unlikely that you will need anything …

Member Avatar for martin5211
0
175
Member Avatar for erogol

I guess you don't want to write a sound hardware driver or anything too low-level, so have a look at JMF - the Java Media Framework. This gives you an API you can use to play media files within some app that you write for yourself. It's about as straightforward …

Member Avatar for erogol
0
144
Member Avatar for SaranyaKrishnan

I don't know anything about matlab, so ignore this if its wrong, but, if Areas is a class that wouild be consistent with the error message "Undefined function or variable" (a class is neither a function or a variable). Is "t" a thing that can refer to a class as …

Member Avatar for SaranyaKrishnan
0
176
Member Avatar for steveh000

Use a javax.swing.Timer to schedule the pull updates. Easy, Safe. ps: Java 6 (1.6) introduced the SwingWorker class to handle exactly this kind of situation (background task with progress reports and a final result to the GUI) - it may be a bit late for your code, but have a …

Member Avatar for steveh000
0
105
Member Avatar for NewOrder

Its not common to see one package per class like that. Normally you would have a package, say "chess", with all those classes in it. That way you can make best use of the different scopes (private/protected/public etc) to share the things you want to share between your classes while …

Member Avatar for NewOrder
0
318
Member Avatar for Premsathishbe

"Enhanced for loop" - new in Java 1.5, and very good. Read it as "for each double d in numbers" It copies each element of numbers in turn to a new double, and executes the loop once for each. You can use this for arrays, lists, all kinds of collections, …

Member Avatar for tong1
0
94
Member Avatar for P00dle

Dunno about your threads - it looks somehow much more complex than I would have expected just to multithread these searches. But anyway, you haven't fully followed my correction to your regex, so your regex is still wrong, but this time it's too liberal. By not escaping the . with …

Member Avatar for P00dle
0
168
Member Avatar for neo_31591

First fix this basic problem. To compare two Strings for the same content you can't use ==, that just tests that they are exactly the same object. You need string1.equals(string2)

Member Avatar for JamesCherrill
0
102
Member Avatar for rowley4

NormR1 wrote:[QUOTE]You can not define a class inside of a method. [/QUOTE] Sorry Norm, that's wrong. Just try this: [CODE] void m() { class C { } new C(); }[/CODE] You can define a class in a method, and its scope is the method, just like a variable defined in …

Member Avatar for NormR1
0
2K
Member Avatar for Megha SR

Its a special method that is called when a new instance of a class is created. It's used to initialise anything that needs to be initialised for a new instance. Every class needs at least one, and if you don't supply one the compiler gives you a "default" constructor that …

Member Avatar for Xufyan
0
117
Member Avatar for Megha SR

A char is just that, ONE character. 'and' is not a valid char. You want to do a switch on Strings? Don't we all. You can't. It may be introduced in Java 1.7. Have a loook at Hashmap - it allows you to build a lookup table with Strings as …

Member Avatar for jon.kiparsky
0
125
Member Avatar for NewOrder

[QUOTE]is that how it works, 1) create a reference to the interface (reciever). 2) use a constructor to allocate a reference (r) and make it equal to the object reference, 3)then call the interface by a method (sendText), which would put an argument/parameter in it 4)implement teh interface on a …

Member Avatar for NewOrder
0
119
Member Avatar for glenak

Is the class not serialisable because the writer didn't declare it as such, or is there some real reason why it cannot be serialised? Most classes that just contain ordinary data can be serialised - it's normally only a problem if they have handles into non-Java stuff in the operating …

Member Avatar for glenak
0
137
Member Avatar for Shaaani

Java is checking that retCode will always have a value assigned, no matter which path through your code is executed. If, for example, the getConnection fails, it will go straight to the catch, and retCode will never have a vaue assigned to it. You can either intialise it when you …

Member Avatar for NormR1
0
124
Member Avatar for thilinam

Perform you function in a Swing Worker Thread, not on the Event Dispatch Thread. I have no time to explain this now, but Google will help.

Member Avatar for JamesCherrill
0
110
Member Avatar for abhikr7891

Perform you function in a Swing Worker Thread, not on the Event Dispatch Thread. I have no time to explain this now, but Google will help.

Member Avatar for abhikr7891
0
212
Member Avatar for Xufyan

Also, if your test char is 'X' then lower-casing the String will guarantee no matches. To do a case-insensitive match, convert both the String and the test char to the same case (lower or upper, doesn't matter, as long as they are both the same).

Member Avatar for NormR1
0
137
Member Avatar for Xufyan

To expand on what norm said: A char is a numeric primitive - its a 16 bit number that's used to hold a Unicode value representing an individual character in some chosen characterset. Primitives like char do not have methods. A String is an Object that holds some text as …

Member Avatar for HeidiC
0
452
Member Avatar for junichiro90

It depends on how you want to access the data. Do you intend to read it all in at the beginning, or do you need to read things in dynamically, as queries? Similarly, when/how do you update the stored data - transaction by transaction or all in one go?

Member Avatar for JamesCherrill
0
103
Member Avatar for bibiki

NormR1 wrote: [QUOTE]Your are expecting the constructor of your class to return a value. If you look at the syntax for a constructor you see that it does not return any value.[/QUOTE] Sorry Norm, that's wrong. You don't get to specify the return value because a constructor ALWAYS returns the …

Member Avatar for JamesCherrill
0
77
Member Avatar for khRiztin:)

The Date class should help. It holds not just the date but also the time in mSecs. Its default constructor initialises it to the exact time it was created. Its getTime() method returns mSecs, so you can do this: [CODE] long start = new java.util.Date().getTime(); // do whatever long end …

Member Avatar for khRiztin:)
0
108
Member Avatar for NewOrder

Hi jon An (non-static) inner class has access to the instance variables of its containing class, and so it must be accessed through an instance. Static inner classes have no access to instance variables. [url]http://download.oracle.com/javase/tutorial/java/javaOO/nested.html[/url]

Member Avatar for jon.kiparsky
0
93
Member Avatar for BestJewSinceJC

Because Integers are final, and can't change, maybe the compiler optimises by creating one Integer(5) and pointing both refs at it (like Strings). ? ???

Member Avatar for BestJewSinceJC
0
109
Member Avatar for glenak

readObject returns an Object, and given that it's reading it from a Stream at runtime, there's nothing else it can do. You have to cast it to the right class before you can use it fully. There's no way to avoid an unchecked cast in this case. You may want …

Member Avatar for glenak
0
19K
Member Avatar for neigyl_noval

Check that the while loop is being executed by putting a print statement in it. Similarly use prints to confirm that the right cases are being executed in all those nested switches

Member Avatar for JamesCherrill
0
347
Member Avatar for NewOrder

In general: if you hide your internal implementation behind gettersthen you can change the implementation without breaking any other code that uses your class. Ways in which you might change include: Changing the private data type (eg Date to Calendar) Waiting until someone requests a value before creating it (eg …

Member Avatar for JamesCherrill
0
180
Member Avatar for NewOrder

1. animals[i is an Object (as far as the compiler knows, because that's how you declared it), and Objects don't have a makeNoise() method. The code checks that this particular Object is in fact a Cat, the uses the cast (Cat) to tell the compiler that this particular reference to …

Member Avatar for NewOrder
0
118
Member Avatar for iSax

I say "yes". Would be an even better algorithm if you replaced "100" by "n" thus making it general

Member Avatar for JamesCherrill
0
99
Member Avatar for P00dle

How about some basic debugging? after line 12 print the name and the strRegex to see if they are both what you expected. ps does this mean that yesterdays dangling metachar thread is now "solved"?

Member Avatar for P00dle
0
135
Member Avatar for drizzled42

[QUOTE]I am a graduating student, taking up BS IT. Unfortunately, i don't have a talent in the field of programming[/QUOTE] I don't mean to be funny here, but maybe you should be looking at a different career path? Better to face the facts now than to launch into some field …

Member Avatar for coil
0
200
Member Avatar for Waseem Siddiqui

create a new method in the subclass to pass the call on to the superclass, yhe call that instead public void superA1() { super.a1(); }

Member Avatar for JamesCherrill
0
222
Member Avatar for ahsan1

Windows? Put the jar in your JRE (not JDK) installation folder in the JRE6/lib/ext subfolder. If by API you mean the api documention, that can go anywhere.

Member Avatar for JamesCherrill
0
61
Member Avatar for signum89

My guess is that there won't be many people wantinmg to go thru your code line by line debugging it (me included), so here's the next best thing - some help for you to debug it yourself. What I don't see in the code is a whole load of System.out.println(key …

Member Avatar for NormR1
0
225
Member Avatar for lisa.wells7

"not working" in exactly what way? If there's an exception or error message please give the complete text. If the result is wrong, please let us know what you expected and what yuou got. Is dancersList a non-null instance of List<aClass1>?

Member Avatar for lisa.wells7
0
207
Member Avatar for idontknow19

[QUOTE]to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.[/QUOTE] OK?

Member Avatar for jon.kiparsky
0
129

The End.