Java Definition and 587 Threads

  1. J

    Java Is there anything wrong with this Java code?

    I had a phone interview with a guy and I thought it went well. At the end he told me to send him a Java program that reads from a file containing a list of integers, one per line, and prints out all the pairs that sum to 8. I thought I made a pretty good algorithm that finds all the pairs that...
  2. C

    Java Why Does My Java Graph Show Incorrect E Field Values?

    I am using JAVA to generate a graph of the E field close to a conducting plane. The result which I want to graph is $$E_z (x)= \frac{Q}{2\pi \epsilon_o} \left(\frac{d}{(x^2+d^2)^{3/2}} - \frac{h}{(x^2+h^2)^{3/2}}\right).$$ The code is below: import java.io.Console; import java.io.*; import...
  3. A

    Java How to Adapt the Nelder Mead Algorithm for a Custom Function in Java?

    Hi This is a question somewhere between maths and numerical methods... I am using the algorithm for Nelder Mead found here: http://www.ssl.berkeley.edu/~mlampton/neldermead.java in java. It works nicely with the two example functions - rosen and parab. I am trying to adjust it to my function...
  4. A

    Java How Can a Beginner Tackle Learning Java and Android Programming?

    I'm an undergraduate, and I have a scholarship to help do research with one of my professors. He's assigned me to learn Java and how to program Android apps. I have absolutely no programming experience. It seems like they expect me to get it down in a couple of weeks, but there is just so...
  5. T

    Java Suitability of Java for computational physics, as compared with C or F

    I have recently begun physics graduate school. My own programming background is in Java, but I haven't done much computational physics of a caliber that required me to implement things *well*. My research advisor states that most of the numerical simulation that takes place in our field...
  6. N

    Java Best way to learn Java in 3 months?

    I'm joining my school's FIRST Robotics club, and our supervisor has said that we will be using Java to program our robot this year. I have self taught myself Python and enjoyed it, but does any pone have any advice/tips/links for helping learn Java? I know it's a whole different animal...
  7. A

    Java What is the problem with excessive indentations in Java if-else statements?

    Hello everyone. I am a little confused as to how I should organize if else statements in java. Here is an example from my Leap Year program: if (x<1600) { System.out.println(setError); } else if (x>2013) { System.out.println(setError); } else { if...
  8. J

    Java Unable to run Java applet on my machine

    Hi, I'm running Internet Explorer 10 and when I go into manage add on, I see Java is enabled. However, when I try to run the applet in this link http://www.certicom.com/index.php/33-experiment-an-elliptic-curve-model-over-fp about elliptic curve cryptography, I'm unable to run it. I...
  9. P

    Java How to Get the Rectangular Form of a Complex Number in Java?

    Hi, I'm doing a mini-project in java that involves some nasty calculations with complex numbers- particularly with complex numbers in exponents. Thus far, I've had success using this class: Complex.java . The problem that I'm encountering involves taking the natural logarithm of a complex number...
  10. C

    Comp Sci How can I fix errors in my Java Complex Number Class Homework?

    Homework Statement Create a class which contains the following: a)instance variables for the complex number. For x+yi, x and y are the variables. b)constructor to initialize these variables. c)methods to return the real and imaginary parts of the complex number d)method to compute the...
  11. Y

    Java Solving Java Installation/Uninstallation Problems

    I have problem with installing and uninstalling Java. Some of my work cannot be completed without a working Java. I tried to uninstall Java(TM) 6 Update 37 , it gave me an error message: Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to...
  12. C

    Comp Sci Simple program to sketch graph in JAVA

    Homework Statement See code below: The Attempt at a Solution I am simply trying to get the code to work: When I try to compile, the terminal says that apparently the package ptolemy.plot.* package does not exist and so does not recognise statements like PlotFrame etc.. Why is this...
  13. B

    Java Need some help with an equation(s) for a basic Java program

    I am writing a basic program using Java. The function is to break up any number the user inputs into smaller values, the catch is that these smaller values have a maximum usage and the overall result has to use the combination with the highest amount of values. I am figuring out the code just...
  14. iamjon.smith

    Comp Sci Java Array Problem: Wizard/Elf Character with Random Health and Gold Points

    Ok, I have a java app that allows you to choose a class (wizard/elf) and is supposed to give a random amount of health (an array with 10 values) and 25 points of health. When I run the program it gives me the memory location from the array and not the value. I know I am missing something simple...
  15. Todee

    Java How to make a search engine by Java ?

    want some sites to teach me how to develop a simple web-based search engine that demonstrates the main features of a search engine (web crawling, indexing and ranking) and the interaction between them. Using Java :confused:
  16. J

    Java Java question: Need some sort of global variable.

    Just wondering if the Java experts here could help me. As part of a project I'm making a function rand9() that returns a pseudo-random number 0 through 9. The problem is that each time it's called I need a certain number to increment so that it can generate a new (not necessarily different)...
  17. A

    Comp Sci Java Tic-Tac-Toe Project: Create a Game with Unique Position Restrictions

    Homework Statement So, we have a project to make a tic-tac-toe game and for bonus points we can make sure the player(s) can not enter the same position more than once. I can't think of a way to do this. I'm sure I need to use a 'for loop' or a 'while loop'. I am using eclipse to write the...
  18. S

    Java Which Resource is Best for Learning Java: Online Tutorials or Printed Books?

    For learning C and for references, " The C Programming Language" by Dennis Ritchie and Brian Kernighan is an authentic. Which book should I refer to if I need to learn Java the same way?
  19. trollcast

    Looking for a Book to Learn Java and OOP?

    I'm currently trying to learn java and I've managed to pick up most of the basics from tutorials and stuff on the internet (loops, conditionals, defining functions etc.). However none of them provide a good explanation of OOP and how to use it in java, except for a very trivial example like...
  20. J

    Java This error (Java) is confusing me

    It's saying I don't have an 'if' statement for my 'else if' statement, but I do. You can see clearly from this picture that I do.
  21. J

    Java [Java] Can't figure out this Illegal start of expression error

    [Java] Can't figure out this "Illegal start of expression" error From my Java code: while (info.substring(j, j)) != " ") { name += info.substring(j, j); j++; } gives an "illegal start of expression" error
  22. O

    Comp Sci Java Help: Decimal Format Class

    Homework Statement Problem: Tele-Annoy, a telemarketing company has asked you to write a program that when given the area code to dial, generates the next three potential telephone numbers, and then outputs them to the screen for one of their sales representatives to call. Use the area code...
  23. S

    Java [Java] what's wrong with my bubble sort algorithms?

    I have 2 possibilities, non of them worked: PD: I am sure that all the methods inside this method(s) are correct and I am sure that the program's GUI is refreshing effectively. public void metodo1() { for (int i=0; i<(perros.size()); i++){ for (int j=perros.size()-1...
  24. M

    Java [JAVA] Question about data flow betwean methods

    Hi, Wanted to ask you guys how does Java know what specific parameter to take into a method if the method name has to be only - let's call it - "internaly consistent" (meaning the parameter in the head and the body have to be the same). E.g. if I pass a value to the method: private int...
  25. M

    Java [JAVA] I seem to always need to enter the class path to run the program

    Hi, I wanted to try to use cmd to compile and run a program in java. I have sucessfully compiled it. The compiler is working properly (C:\new> javac output the compilers functions), but I'm always getting the same error: "Error: Could not find or load main class hello". When I specify the...
  26. O

    Comp Sci Java GUI program determining retail price, does not finish running

    Homework Statement Just trying to finish up this assignment, no errors. I run the program, enter a value and a percentage, then click calculate. Program just runs, never displays results. Check my code below, let me know if something is wrong. Driver: package ch7pc1; import javax.swing.*...
  27. Hercuflea

    Java Java noob - help setting up eclipse

    Hello and thank you for putting up with this noob question. The directions on the website or anything I have found on the internet are not very descriptive. I have downloaded Eclipse and Java JDK version 7 and successfully installed both of the applications on my computer, but I must have...
  28. F

    Java Trying to come up with simple algorithm of significant time complexity in Java

    Hi PF, I'm working on a program that requires measuring how long it takes a given computer to process a certain task, but am having trouble coming up with algorithms that won't take most computers a trivial amount of time to perform. The only one I've got so far is recursively computing...
  29. P

    Comp Sci Java Non-Recursive du command popping java.lang.InterruptedException

    Homework Statement You are to write a robust program (i.e., a public static void main()) that accepts a file pathname (e.g. 'c:\foo\bar' or '/home/jblow/' under UNIX) as input and then calculates and prints the size of that filesystem object: java FileSize c:\foo\bar 123625 bytes The purpose...
  30. C

    Java Very simple java program not working

    I am using the netbeans IDE All I am trying to do is print out to the screen, but I keep getting this error. Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: system.out.println at mysqlconn.mainhgf4.main(mainhgf4.java:19) Here is my...
  31. T

    Comp Sci [Java] Generating a Time Array Problem

    Homework Statement I'm given a maximum time, a time step (or interval) and I'm supposed to form an array from 0 to the maximum time going up by timestep each time. double tMax; //maximum time double tStep; //time interval to go up by Homework Equations Our teacher told us to use the...
  32. U

    Java [JAVA] please tell me this for loop

    Hey guys, I have an ArrayList<String> al = ArrayList<String>(); and I have a textbox, the textbox allows a user to enter a word and that word will be added into the ArrayList. When I print the list out it looks like this [Cat, Dog, Mouse] can you please write out the for loop that I need...
  33. S

    Java [Java] what the hell am I doing wrong with this graphical interfaze?

    I have a package with all the classes needed to perform the functional recquirements (calculations, etc.). It's working perfectly. The "main" class is "FinalesCopaMundo" I have another package with all the classes needed to perform the GUI. The "main" class is "InterfazFinalesCopaMundo". I...
  34. U

    Java Java GridLayout for Applet Window: Add, Display, Search, and Remove Words

    Can anyone tell me how to get the Textbox to the bottom of the applet window? public void init(){ setLayout(new GridLayout(6,0,5,5)); al = new ArrayList(); addNewWords = new JButton("Add Word"); displayAllWords = new JButton("Display Words")...
  35. perplexabot

    Java Debugging Java Quicksort Code: Tips and Tricks for Optimal Results

    Hi all. I am currently working on quicksort and have written the following code and gives "almost" good results. I am not too fond of the data structure I have chosen but it is too late for me to change. Lesson learned. Can anyone help me debug this thing. I have been at it for a while. Anyway...
  36. C

    Comp Sci How Do You Design a Circle Class in Java with Overlapping Circle Detection?

    Homework Statement Homework Statement I need to write a class that represents a circle object and includes the following; -Private Class variables that store the radius and centre coordinates of the object. -Constructors to create circle objects with nothing supplied, with just a radius value...
  37. T

    Java Returning a Correctly Sized Array for Dive Moves

    If I have a program where I need to return an array, is it possible that I only return the array with the length of what was added to it? What I mean is I have an array that gets filled up with letters but it doesn't always get completely filled up. Is there a way I can only return the...
  38. C

    Comp Sci Java Program for Damped Harmonic Oscillator Solutions | Ptplot Package

    Homework Statement I have to write a JAVA program that will compute and display (via the ptplot package) the solutions for the damped harmonic oscillator (x against t) in some given range for t. The solutions vary depending on how gamma and omega are related. The instructions given were: 1)...
  39. F

    Java Timing a Task in Java – Find Out How!

    Hi PF, I am trying to write a program that utilizes a for loop that skips the current iteration (via continue) if it takes too long (for instance, longer than 20 seconds, else it finishes the current iteration as per normal), but am not sure how to best do this. Does anyone know of a way...
  40. R

    Java [Java] Class and Driver Class help

    Hello, I am trying to figure out what I did wrong and I couldn't figure it out. here is the error code: setMake(java.lang.String) in Automobile cannot be applied to (). Class file: import java.util.Scanner; public class Automobile { private int num; //number of automobiles to...
  41. C

    Comp Sci Java ArrayList Help: Troubleshooting Unexpected Type Error

    Homework Statement I'm working on a program that uses an ArrayList to hold a collection of UserID objects (which contains the first and last names, plus username and password). When I add a new UserID to the list, I want to check to make sure that it is not already there. This is the error...
  42. S

    Java Problem defining a constant in java

    I have: public final static int NUMERO_ESCENARIOS=4; escenarios = new escenario[NUMERO_ESCENARIOS]; having an error in the first line that says: Syntax error on token ";", , expected but when I have: public final static int NUMERO_ESCENARIOS=4 //semi colon deleted escenarios =...
  43. H

    Java Java: PNGException: Premature End of JPEG File

    I'm getting this error sun.awt.image.PNGImageDecoder$PNGException: crc corruption at sun.awt.image.PNGImageDecoder.getChunk(Unknown Source) at sun.awt.image.PNGImageDecoder.getData(Unknown Source) at sun.awt.image.PNGFilterInputStream.read(Unknown Source) at...
  44. L

    Java Compiling multiple paged java project

    i have been learnin java for about two weeks. i have gone through simple programin and some other programs includin GUI through swing. till that i was working with single form programs that can be compiled by using "javac" and executed by "java" syntax.now to try better i downloaded a java...
  45. Hercuflea

    Comp Sci Java - calculate nth Fibonacci number

    Homework Statement Hello everyone, I am trying to write a java program that asks the user to input a number n, and the computer calculates the nth Fibonacci number. I am supposed to use a loop to calculate the problem. My question is, how do I set up the loop to calculate the nth...
  46. M

    Java Confused about Java and Glassfish

    Hello, I just downloaded the Java Development Kit (J2EE) and during the install I was asked to configure something called Glassfish. I don't understand what Glassfish is for. Is it only for Web development? What does it do for me?
  47. C

    Comp Sci Java- Missile prgm using parallel guidance

    Hello all! So I am working on a Java program and we have introduced artificial intelligence to a missile that is hunting a flying aircraft in 2d. The purpose of the program is to compare 3 different guidance systems--pursuit, proportional, and parallel. I am stuck on parallel! We have the...
  48. M

    Comp Sci Write a Java program to convert binary numbers to decimal numbers.

    Use a loop to read (charAt()) each digit (0/1 char) in the input string, scanning from right to left; Use the loop to build the required powers of 2; Use a conditional statement to deal with 0 and 1 separately; Debug using simple input, e.g. 1, 10, 101, and print intermediate values in...
  49. S

    Java [Java] error:can not find symbol. I don't know what the hell is happening

    import java.util.Scanner; import static java.lang.System.out; import java.util.Random; public class wolf { public static void main (String[] args){ int hitpoints = 100; int damage = 40; //un numero cualquiera, solo para hacer una prueba Scanner keyboard = new Scanner(System.in)...
Back
Top