4,084 Posted Topics
Re: a reason why you yourself would/could use private constructors, is implementing the Singleton pattern. for instance, if your conection with your db should all be done with the same instance, you would have something like this: [Code=Java] public class ConnectionManager{ private static ConnectionManager instance = null; // other variables private … | |
Re: an if statement, maybe not, an expression.. why not? remember, the expression of an if statement always will turn out to be a boolean. [Code=Java] public static void printResult(boolean b){ if ( b ){ System.out.println("the expression = true"); return; } System.out.println("the expression = false"); } public static void main(String[] args){ … | |
Re: write a method that determines whether a number is a prime number or not set counter to 0 set number to 0 loop while counter < 8 { number = number + 1; determine if number is a prime if ( true ) { print number add 1 to counter … | |
![]() | Re: what exactly is your 'in'? if it's not a Scanner object, there's indeed something wrong with your code. also, I don't see any exception handling there. no doubt you're supposed to throw and catch an exception. |
Re: [QUOTE=jade_91;1740758] [CODE] if (closest.name.equal("Wesston-On-Shore")); return ("Docks Line") [/CODE] not sure if this is correct plus how you 'name' it to recall in the display for the user any help would be appreciated[/QUOTE] well.. what is your method supposed to return, if anything? a few mistakes in the above lines anyway: … | |
Re: keep a static int, in which you keep your index. if that int < the length of the array array[yourInt] = new Connection(); // NOT connectionManager, according to your assignment and then return array[yourInt]; if ( int >= length of the array) return null | |
Re: [URL="http://shop.oreilly.com/product/9780596009786.do"]O'Reilly book[/URL] | |
Re: little remark about the original question, but I assume you figured it out already :) it's not the constructor <<I was just wondering why the constructor makes a call to the method toString() then I <<have realised that it's because of the method's name. the constructor doesn't make a call … | |
Re: and you may want to add a return statement to your if. otherwise, it'll do all the iterations you know will be false, because you already found the one you needed. | |
Re: no, we would be violating forum rules. you may want to take a close look at the first thread in this forum, it contains a lot of helpfull links and information to help you get started. | |
Re: you can have unlimited classes in one file, but you can only have one public class in one file, and this class needs to have the same name as the Java file. | |
Re: what do you have in your main method? with this I mean: how have you tried to call your insert method? is this code all within one file, or separate files, ...? can you be a bit more specific? | |
Re: did you Google read write file java yet? one of the results returned is [URL="http://docs.oracle.com/javase/tutorial/essential/io/file.html"]this[/URL]: oracles tutorials on how to read and write files, with example code. | |
Re: check the path of your file (if it has to be a .txt file => if !path.endswith(".txt")) false your values in your file : read them all into variables and check the values you get. but you'll need to be a bit more precise into how you want to validate … | |
Re: [Code=Java] System.out.println(e2.count); [/Code] this line is a print, it prints the value of the count variable of your instance of echo. if you add a print statement in your while loop, you will see how many times it runs. if you copy the above print within the while loop, you … | |
Re: the z: refers to the for loop, but you can't use it to refer to a single expression like o = o + 2; [URL="http://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html"]here[/URL] is a link you might find usefull to get to better understand the labels | |
Re: that depends on what arguments you pass. for instance, it won't work if you pass: -x100 since this will be the argument. also, you could optimize your test to check if the right number of arguments were entered: [Code=Java] switch(args.length){ case 4: // handle your arguments here, or set a … | |
Re: looks to me like your code is trying to use these classes, but doesn't find them in it's classpath. | |
Re: that are two different instances of the hspersonnelinvolvedclass-class, which means, for the instance in your second form, you never executed that setText method. if you want them to work with one instance, you'll have to pass a reference to that instance to the second form. | |
Re: personally, I never used JWindow, but you should be able to use both. | |
Re: maybe not necessarily to solve your problem, but if you want to define your own threads, it's better to implement Runnable, than to extend thread. the only reason why you should extend is if you want to change something in the basic functionality of the object, which is most likely … | |
| |
Re: what do you mean? you have your command line args, they are stored in your [B]args[/B] array [Code=Java] public static void main(String[] args){ } [/Code] | |
Re: roman.toUpperCase??? I assume you'll use your instance of Scanner (roman) as a means to read a String instance, which you'll then set to UpperCase and why this: return -1; break; return automatically ends the method by returning the value. | |
Re: well ... this has not very much to do with what JDK you are using, more as what type of object you use where and which you should use where. also, you could have created a new thread for this. | |
Re: [QUOTE=connect2abhi;1738051]Hi I have a class A,B and C. Now B and C extends A. So is there any way that we can call a method of B in A? [/QUOTE] possible? off course. but ... a bit fishy. this would imply that A knows the type (whether) or not it … | |
Re: best thing is still to come up with something you are genuinely interested in: that way you won't loose motivation to work on it. also: you told us nothing about your course, what you've learned, what (if any) limitations you were given, .. a number of professors I've had used … | |
Re: ehm ... an editor and a compiler? I think you'll need to be a bit more specific. depending on the kind of game, you should consider which first. do you mean: writing a game from scratch, or do you want to make a mod for an existing game? then you … | |
Re: [Code=Java] while(true) [/Code] the chance of this expression ever returning false is ... well, zero :) | |
Re: create a <div class="errorBox" (or id="errorBox" > </div> add a textcomponent in there with no text in it. as a default, you'll set the visible:false in the css for that div (class or id) and when you have an errormessage to show, you set the value to true, and set … | |
Re: when you call System.out.println(sb3); a bit hidden by the compiler, this will call the toString method of your Object: System.out.println(sb3.toString()); so, it's quite normal it gives the same result :) | |
Re: you may want to be a bit more specific I assume using a textArea to write one, a Button to add it to your savedComments, and a small 'X' button in a subpanel that contains a comment linked to a deleteThisComment function would do the trick. that is, if you … | |
Re: didn 't you just recently create [URL="http://www.daniweb.com/software-development/java/threads/406861"]a thread[/URL] on this issue? why didn't you do what they suggested there? besides: [Quote] Please provide me solution for this im stuck with this. [/Quote] is a big NO-NO. first you'll have to provide any evidence you tried at least something yourself (and, … | |
Re: since in your other thread, I gave you this as a suggestion, what have you tried so far? and why did you start another thread? you could have asked issues about that in your other thread. | |
Re: why re-opening a dormant thread? if you have any questions about this, you could easily have started a new thread. also, it's against forum rules to just hand out custom code. have you or are you currently working on a similar project? if so, and you're having trouble with it, … | |
Re: keep an array, or a list with types you've already added. when you create a new one, check in that array or list whether it already exists, if not, add it to the list, if it does, ignore it and create a new one. for future reference, when you say: … | |
Re: what do you need two main methods for? I don't know what your vision about a "library" is, but AFAIK, a class library has no use for a main method. | |
Re: I see no reason as why System.out.println("heat"); would terminate your screen. can you show your entire code? also, why are you using two dimensional arrays if you're only using the first element? a default array would be sufficient. | |
Re: try putting your main method into the Static_demo class, and remove the inner class where you've actually put it in. | |
Re: here's your problem: [Code=Java] userString = userString.toLowerCase(); [/Code] you set your String so, that it consist solely out of lowercases, so ... no, it doesn't work, since the char you compare it to, is still upercase | |
Re: as Peter_Budo already mentioned: pdf's can be protected in a way that highlight and copy-paste is no longer a possibility. back to the OP: the possibilities depend on what pdf it is you are trying to copy. | |
Re: by passing them as parameters, no doubt. do you know how to use the HttpServletRequest and HttpServletResponse? I think you'll be better of asking any servlet/jsp questions in the webdevelopment>>jsp forum | |
Re: why didn't you keep this in the other thread about this code? you have two major issues with this code 1. this [Code=Java] else if (ans == 0); { } [/Code] is placed within a [Code = Java] if ( ans == 1 ) [/Code] block, and will therefor never … ![]() | |
Re: you can create a small method, where you convert your float into a String, with the separator (the ,) on the correct spot. then you return that String and place that in your printf command | |
Re: the problem is you are overwriting the value you have for aveCost, instead of correctly calculating it and later on calculating the average. | |
Re: but make sure you have an instance of the Scanner class on which you can run the methods of the Scanner class. to see how it works: look [URL="http://docs.oracle.com/javase/6/docs/api/java/util/Scanner.html"]here[/URL] you must also ask yourself: will you only use this value in this method, or do you need this value in … |
The End.