- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 7
- Posts with Upvotes
- 6
- Upvoting Members
- 4
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
52 Posted Topics
Re: The first clue is the type of Array you are using. You should be using an implementation of java.sql.Array, not java.util.ArrayList. Check the javadocs on its use, and you will probably get a little further. | |
Re: Your program also doesn't compile. The BufferedWriter doesn't have a method named "writer". In your "for" loop, you call that non-existent method. Probably a typo? Anyway, pay attention to your compiler output - it should have given you an error message about it. | |
Re: Well, as @stultuske said, read each line in your while loop. You'll need a variable, declared outside the loop, to hold the data you read. Probably a List of some type, though you could use an array []. When you read the line as a String object, you'll need to … | |
Re: So, you want to do something like: [CODE]Map<String, Object[]> objectMap = new TreeMap<String, Object[]>(); Object[] values = new String[] {"A", "B", "C"}; objectMap.put("First3Letters", values); [/CODE] Is that right? Yes, you can do that. | |
Re: A very simplistic way to do it is to have 2 arrays; one to hold the quotes, the second of the same size to indicate whether a quote has been used or not. So, you might initially fill the second array, which indicates whether a quote has been used, with … | |
Re: Accessors and mutators are methods that retrieve or change the value of a class's instance variables. The naming convention is set<VariableName> or get<VariableName>. Thus, if I had a class with with an instance variable [code]private String cat[/code] , I would create an accessor [code] public String getCat() {...}[/code] and a … | |
Re: By "runs on a library" I'm assuming you mean it will be an executable jar file. But I don't know what you mean by classifying your program as a script. Are you planning on writing a program to read some text files that serve as scripts in some particular syntax? … | |
Re: Well, you probably don't really want to load the *jar* itself, you want to load one or more classes that happen to reside in the jar. In that case, you need to have that jar on your java classpath so that the JVM can find that/those classes in the jar … | |
Re: And you'll probably need to use JNI (Java Native Interface) to do it. You can check out the Java 6 guide here: [url]http://download.oracle.com/javase/6/docs/technotes/guides/jni/[/url] | |
Re: It's probably because you have the mysql.jar configured in your classpath for Eclipse (that's part of the process when you set up a datasource in the Eclipse database explorer, for example), but it's not in the classpath in your windows environment. You can set the CLASSPATH env variable to include … | |
Re: is the data in the database corrupted as well? If not, perhaps your file writer is not being flushed, over-running a buffer, etc. What do the log files say, if anything? Are there any IOExceptions being thrown? | |
Re: If you use stultuske's approach, I would tend to use a StringBuffer or StringBuilder instead of creating a new string every time through the loop. I know this is a small example, and memory/garbage collection isn't really a priority for you right now. I only bring this up because if … | |
Re: You may also want to look in to open source HTML parsers such as Jelly and Jericho. I can't recommend one over the other, but they have some very useful features that may help you. | |
Re: There are several JVM options that will increase the heap and stack size of the vm. Besides finding out what is eating all the memory, as James pointed out, you can look at garbage collection stats (java -verbose:gc, which will show, at least, how often the GC is running. You … | |
Re: Personally, I would start with Java SE - it will give you the basis for other java editions, such as SE and EE. Once you learn to write simple effective java, you can move on to more complex concepts. | |
Re: You may also want to turn verbose garbage collection on and see how much time the program is spending collecting garbage. If it's a lot, it could indicate that your java heap is too low. (It's adjustable, just google java garbage collection and heap size adjustment). If you are using … | |
Re: In my opinion, you don't need to learn awt first. The basic concepts are the same with both, but with different components and they way they interact. The most important things to learn are how to build up components (adding a label and a button to a JPanel, and adding … | |
Re: Lots of good resources on the net - here's one: [url]http://www.coreservlets.com/JSF-Tutorial/jsf2/[/url] Also covers JSF 1 | |
Re: Just as a matter of convenience, there is a LineNumberReader available that will keep track of what line you are on - not sure if you need it, you may be just keeping your own counter, but I thought I'd bring it up. | |
Re: Not knowing anything else about the code, could it be a capitalization problem between p.getName() and playerName? Try [CODE]if(p.getName().equalsIgnoreCase(playerName))[/CODE] and see if that helps. | |
Re: It's a best practice to make all instance variables private (or protected at least). In this way, you are enforcing the concept of encapsulation. The only time I use public instance variables public is when they are constants, such as [CODE]public static final String ACCEPTABLE_PUBLIC = "Acceptable public variable";[/CODE] Others … | |
Re: Not being able to see all of your code, my first guess is that jFileSave has not been instantiated. Also, what is your CustomFileFilter extending? Are you sure you have initialized it correctly? Without a stack trace, it's hard for me to guess where the problem might lie. | |
Re: Also, I would condense your large collection of variables into a separate class, and make some of your variable names more descriptive. "int h=0; //number of student name in the file" is completely unintuitive. In terms of the formatting of the output, you can use the String.format() method to get … | |
Re: Use split("//s") on your String object to form an array of words from the input. Then, reassemble the string, using your replacement word for the first element of the returned array, and the rest of the words in order from the array. A best practice is to use a StringBuffer … | |
Re: You can use the java.io.LineNumberReader, which can take a FileReader object in the constructor. The readLine() method on LineNumberReader will return one line from the file as a String. Why not use an ArrayList<String> to store the lines read? That way you don't have to know ahead of time how … | |
Re: This is a complex problem that you will need to split into simpler parts with attainable tasks. Are you successfully send a message to the server and receive a response? Think about what your messages will look like when they are sent to the server, and received by the client … | |
Re: Yeah, it's a bit long, and there are other ways to solve what you are achieving, but overall, not a bad job! As far as not having learned what an object is, you're already using them. Your class is an object. String is an object. Math.random() is a (static) method … | |
Re: The simple answer to your threading question is that since no variables are declared as part of the object, but are local to the method, only the thread executing the method has access to them. For a more thorough explanation research the JVM and stack frames. No one here will … | |
Re: As of JDK 1.6, Scanner does not implement the Serializable interface. Here is the declaration from the code: [CODE]public final class Scanner implements Iterator<String> { [/CODE] Unfortunately, it being final means that you can't subclass it either. The only way to get around this problem, aside from writing your own … | |
Re: Here are few initial thoughts. Approach this in small steps. The first step is to make a list of the things you actually need to do. For example, how do you get the text from the forums? This is the first problem I would tackle. There are a number of … | |
Re: You can start by checking out the java.util.GregorianCalendar class. You'll need to study it a bit to understand how it operates with its own fields such as HOUR, MINUTE, SECOND, MILLISECOND, the compareTo() method. If the times are presented as strings, then you'll also need to look at String.split() to … | |
Re: My first thought is to use an implementation of the Map interface, such as Hashtable or HashMap to store your data. The key to the map would be a String for the particular trait such as eye color, and the value would be the corresponding chromosome. Give this a try … | |
Re: Sorry, I won't do your homework for you. The instructions seem pretty straightforward - where are you stuck? | |
Re: What exactly is the problem you are having? Please give us at least a hint as to what is wrong, and please enclose your code in code brackets, using the "{code]" button. | |
Re: If I understand correctly, you simply need to create getters and setters for each of your value objects (Book, BookShelf). You can certainly create a constructor that takes an array of Book objects: [CODE]public class BookShelf(String[] books) { ... }[/CODE] You would be much better off using an ArrayList instead … | |
Re: Are you using an IDE with a debugger? If not, download Eclipse or Netbeans and walk through step by step and find your errors. | |
Newbie here, hoping to contribute some of my experience, and pick up new knowledge as well. Thanks Daniweb team for this site! Don Nelson | |
Re: Your encounter can occur outside of the CyberPet class, using a collaboration pattern. Basically, create another class that has some method which accepts a list of CyberPet objects, compares them, and prints out (or returns) the result. | |
Re: Check out [url]http://jackcess.sourceforge.net/[/url] - that should get you on your way. | |
Re: First, instead of putting all of your work in the main method, move the logic to it's own public method. Then, instead of printing out the results, make this method return a List<String>. Create a second class that calls that method, retrieving the list, and writing the contents to a … | |
Re: Ok, the first thing I see is that you're trying to make a static reference to a non-static method in EmployeePayRoll - that's not allowed. You wouldn't want to do this anyway, since the value would never be saved. In your test class, instantiate an object of type EmployeePayRoll, e.g., … | |
Re: First, your constructor is expecting 4 ints and a double, but you're passing 3 ints, a double and an int to the Delivery class, in your CreateDelivery class. Also, the Delivery class has no such method as "displayFees()", and the variable "deliveryNumber" on line 62 of CreateDelivery is not defined … | |
Re: This makes no sense to me. What are you attempting to do in your switch statement? What is an example of the final output supposed to look like? I suggest you break down the problem (on paper) into simple steps and start over. Use separate methods to address each area … | |
Re: Just jumping in here, but your Asn07Employees class needs a constructor that will accept the arrays it needs to manipulate. You might also consider using three ArrayList classes to which to add the values of the arrays. Then it's simply a matter of setting up some loops to fill the … | |
Re: It would be good to see the code that you have, but as a guess, it sounds like you are supposed to iterate through your doubly-linked list and add each element to a java.util.LinkedList. Could it be that simple, or am I assuming too much? | |
Re: Please put your code snippets within [code][/code] blocks in the future - it makes it easier for us all to read. Can you post your exception stack so we can see what might be going wrong? | |
Re: Here are some points to think about before you open your java editor: 1. What is the simplest thing you can do to make it work? 2. How many people do you want to chat with at one time? 3. How do you identify the person/people participating in the chat? … | |
Re: The Java certification tests will certainly test your knowledge, and they look pretty on your resume, but I don't have any empirical evidence that they'll get you a job. The tests aren't cheap, but it might be worth taking the java programmer test. At the very least, go to the … | |
Re: This works for me: public static void main(String[] args) { long time = System.currentTimeMillis(); try { Thread.sleep(3740); } catch (InterruptedException e) { } long time2 = System.currentTimeMillis(); NumberFormat nf = NumberFormat.getInstance(); DecimalFormat df = null; if(nf instanceof DecimalFormat) { df = (DecimalFormat) nf; double seconds = (time2 - time)/1000d; df.applyPattern("#.#"); … |
The End.