7,116 Posted Topics
Re: What you are asking for can't be done like that, but arrays were invented to solve that problem. You can't dynamically create e1, e2, e3, but you can create an array e[] and dynamically assign e[0], e[1], e[2] etc. ps To test two Strings for containing the same sequence of … | |
Re: Maybe your Hotel should have a number of Rooms (stored in an array Room[]). The checkin/out is something that happens in the Hotel class, but is associated with one of the Rooms? Just a thought... | |
Re: Lines 45-55 you have a while loop that loops as long as there are any tokens to be parsed, and stores them in fName, each overwriting the previous value. Then it drops out of that loop and never executes any of the following while loops because you have already "processed" … | |
Re: You can't "return the println" - that makes no sense. println is a method, not an object. Your usual options would be either to return null or to throw an exception if the find fails to find anything. ps: Remember that you can return from anywhere in a method, including … | |
Re: Sleeping in a Swing GUI usually stops everything from working by blocking the Event Dispatch Thread ("Swing thread") on which Swing handles everything. Its never a good idea. Use a javax.swing.Timer to implement delays and repeated processes. | |
Re: Hi Majestics. Watch out, this is a duplicate post. In the other copy I was trying to get the OP to fix his indentation to find the missing }, but he seemed to want me to do it for him. | |
| |
Re: Line 111. Shouldn't that be props.put("mail.smtp.host", host); ? | |
Re: Assuming you are using Windows, the info you need is here: [url]http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html[/url] Linux is here: [url]http://download.oracle.com/javase/tutorial/getStarted/cupojava/unix.html[/url] In addition you will need to download javax.mail from the Oracle Java website. [url]http://www.oracle.com/technetwork/java/javamail/index.html[/url] | |
Re: Yes, it's completely possible. Just like passing anything else. Beware: you declare the list on line 12, then on line 66 you declare another one with exactly the same name. Probably a mistake. | |
Re: The code inside those if (cases== locks looks very repetitive. Perhaps you can put that into a single method with parameters for those things that are different each time, then just call the method from your if tests. | |
Re: @miltondollar. Please do not violate forum rules. Do not hijack old dead threads. Start you own new thread. | |
Re: WARNING: THIS IS VERY SIMPLIFIED: Methodologies split into two main camps - waterfall vs RAD. Waterfall methods are based on sequential processes - get requirements, then design solution, then code, then test etc. RAD methods are based on building something very quickly then improving it through many iterations. In my … | |
Re: You're not exactly giving us a lot of info on what it is that's not working "properly". If you want help, please start by posting a detailed and precise description of exactly how the actual behaviour differs from the expected behaviour. | |
Re: You are using a package spec employeeinfo.EmployeeInfo, so the compiler expects to find EmployeeInfo.java in a directory employeeinfo - ie your directory structure must exactly match the package structure. | |
Re: Direct access to Outlook from Java is a real pain. It's a COM interface, but com4j seems to have big bugs with Outlook and Jacob is really hard to use (those are the two realistic Java/COM bridges). However, some scripting languages have direct access to COM interfaces, and with the … | |
Re: I guess you didn't notice that the post was from August 2004? I very much doubt that the OP is still waiting for an answer. | |
Re: Unless you have truely gigantic strings arriving a high rate per second then performance is unlikely to be an issue. Much better to find a clear and obvious way to code it, and only worry about performance if it becomes a problem. Just convert to a char array, then take … | |
Re: In real life card games, cards are drawn from one or more shuffled packs, so a more realistic code design would be to create a new "pack(s) of cards" which was a collection (eg ArrayList) of n*52 Cards (n of each), then the draw method just takes a random card … | |
Re: Floating point numbers are represented in binary fractions. (1/2 + 1/4 + 1/8 + 1/16 etc). You fractional value is 0.3, ie 3/10. There is no exact way to represent 3/10 using only binary fractions, so the answer has to be slightly wrong. This is true of all floating point … | |
Re: Using a null layout manager is usually a mistake - layout managers are there for good reasons (different system font sizes on different machines, different screen resolutions, user-resizable windows...). This trick is to chose the simplest layout manager that does what you need. That usually means BorderLayout, FlowLayout, BoxLayout, or … | |
Re: The question requires underflow, not overflow. Underflow is when you try to pop but there is nothing in the stack, eg if you go [CODE]new stack stack.push(something) stack.pop() // OK stack.pop() // stack was empty -> underflow[/CODE] | |
Re: Using a null layout manager is usually a mistake - layout managers are there for good reasons (different system font sizes on different machines, different screen resolutions, user-resizable windows...). This trick is to chose the simplest layout manager that does what you need. That usually means BorderLayout, FlowLayout, BoxLayout, or … | |
Re: I haven't tried this myself but... Java 6 has the new Desktop API that allows you to open the user's default web browser with a URI of your choice [url]http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/[/url] presumably if this is a page that you have written (maybe embedding a remote page in a frame) then you … | |
Re: You have a lot of detailed instructions there already. Just start following them, and come back here when you get stuck. ps Indent your code properly, it will help you as well as us. | |
Re: [CODE]String.valueOf("column name from SQL table")[/CODE] why? | |
Re: Hi guys. I'm jumping in here because I was involved in the original architecture of this app and want to share a bit more background. Transactions arrive unpredictably from multiple clients at a server. The server simply captures the transaction and adds it to a LinkedBlockingQueue. A separate database thread … | |
Re: If you are a complete beginner with Java then going straight to netbeans (or eclipse etc) is not a good idea. (1) A full IDE has its own steep learning curve to add on top of the Java learning curve, (2) A full IDE's tools will fix problems for you … | |
Re: Long/lat map points on a sphere. x,y map points on plane. You can't meaningfully convert between the two except over areas small enough that you can ignore the curvature of the earth. | |
Re: Hi yinp. Although there is nothing necessarily wrong with cross-posting, if you do so it is normal protocol to mention that fact at each site where you have duplicated your post. You will find that many people chose not to waste their time trying to answer a question that may … | |
Re: Just google java printing and you will find many tutorials on how to do it, | |
Re: Original post: Depending on exactly how you want that distribution to go, you may be able to use a fudge like taking a random int 0-5625 then taking its square root. That will give you a smooth parabolic distribution biased towards the bottom of the range (50% of the numbers … | |
Re: @edensigauke: the OP's requirement is to get the value from the runtime parameter(s) args[], so your suggestion about System.in is more likely to confuse than help. @coco24: although @edensigauke's code is not what you need, there is one line that you should have a look at - it's concerned with … | |
Re: Have you created a City class yet (attributes name, number, noOfPets)? That's the first stage. Then you can create an array of City's. When you sort that array each City keeps is own name, number etc; there's no risk of them becoming "not associated". | |
Re: Looking at your posts I see [CODE]if (transferaccount_id==transferaccount_id){ [/CODE] and [CODE]if (intransferaccount_id.equals(intransferaccount_id)){[/CODE] but in both cases you are comparing the [I]same object[/I] to itself! I would expect to see something more like [CODE]if (accountBeingTransferredFrom.equals(accountBeingTransferredInto)) { // can't transfer to same account[/CODE] (but with your own variable names, obviously) | |
Re: Not a bad start. You may be missing one class because your Trade class represents both individual Trades (buy/sell), but also has the list of Users and Shares. Users and Shares belong to a StockMarket. In the StockMarket you can register and delete Users and Shares, and create many Trades. … | |
Re: Use the string method charAt(int index) in a loop to get the chars one at a time. The Char class then has methods to tell you if a char is a letter or a number or whatever. | |
Re: If you want to know which date is earlier then yes, you need to convert both to Date. You can use the SimpleDateFormat class to convert/parse a string into a Date | |
Re: OP has started a duplicate thread for this. [url]http://www.daniweb.com/software-development/java/threads/379499[/url] | |
![]() | Re: Unless you are doing something very special and complex you will never need to use System.gc(); Java will do its garbage collection when appropriate, there's no reason for you to get involved. finalize() is not what it seems. It's run when the object is GC'd, which may be any time … |
Re: Have a look at the SimpleDateFormat class. You will find it has methods to convert (parse) Strings in various formats into Dates that you can add to your list. | |
Re: Note also that if you declare a class as being in package xxx then Java expects to find that class's files in a directory called xxx. So if you add a package spec to a class, you also need to add the corresponding sub-directory and move your files into it. | |
Re: Line 196 It's the same mistake that has already been pointed out to you twice. | |
Re: I haven't studied the code in detail, but I'm not surprised that the execution terminates differently with or without the System.exit. With it the code terminates as soon as the exit square is found. Without it the current invocation returns to the the call on line 42, and the loop … | |
Re: If you look at the correct solution you will notice that each pair consists of an element and a second element that comes later in the array, ie [CODE]for each element i in codesArray for each element j that appears after i in codesArray pairThese(i,j)[/CODE] | |
Re: Class Main lines 10, 17 [B][I]you [/I][/B]make them both visible. Don't make mainframe window visible until after logon. | |
Re: Check out the Arrays class. It has methods for sorting arrays etc. | |
Re: You could easily separate the SQL part (around lines 52-68) into a method with the signature [I]public ResultSet getDataFor(String user, String password[/I]) and that method could be in a different class. That would make the code easier to understand and maintain. But ideally though it would be better to separate … | |
Re: Arrays are 0 based,, so a [5] array has length 5 and indexes 0-4 Your loop for(int i=0; i<=personArray.length; i++){ will attempt to access indexes 0-5, and will fail on the last one with an IndexOutOfBounds (5) | |
Re: Its the full width of the window; just how broad did you want it to be? |
The End.