32,199 Topics

Member Avatar for
Member Avatar for dnanassy

Hello everyone, I'm working on an assignment that requires the use of the Scanner class to read the source code of the .java file and output all lines when executed. I have created a file that works without issues on my machine, but I was wondering if there was a …

Member Avatar for dnanassy
0
505
Member Avatar for Kayla1993

I am doing a project in class. We have to make a program that scans Two Postive Integers, one at a time, using try-catch block. Can some one please help me get started?

Member Avatar for mlesniak
0
116
Member Avatar for venividivici

Hi, my daughter is struggling a bit with maths and logic and I was thinking of doing some programming with her hoping that a different approach to the field might help a bit. I've had some look at Java syntax and I think I should be able to write some …

Member Avatar for JamesCherrill
0
159
Member Avatar for HankReardon

How do you write an input validation loop that compares strings? My attempt at the code is included. Thank You, Hank Question 4.6. Write an input validation loop that asks the user to enter “Yes” or “No”. import javax.swing.JOptionPane; import java.text.DecimalFormat; import java.util.Scanner; /** CIS-151, Input Validation Loop */ public …

Member Avatar for WDrago
0
1K
Member Avatar for WDrago

This seems like a pretty basic question, but I'm still learning Java and all the nuances of OOP. I have several classes in my program and they all need access to the same ArrayList (the one with all the data in it.) What's the best way to share that list? …

Member Avatar for WDrago
0
105
Member Avatar for HankReardon

For some reason I am having trouble comparing strings when inside a while statement using the using the && and || operators. while (input.equals("Yes")) && (input.equals("No")) The error message implies the parentheses are ending the statement prematurely. Can someone please give me a suggestion? Thanks, Jim

Member Avatar for NormR1
0
185
Member Avatar for Ravish.Ahmad.Khan

**Following is the code snippet to print the series:-** *111 211 311 121 221 321 131 231 331 112 212 312 122 222 322 132 232 332 113 213 313 123 223 323 133 233 333* **But there's some mistake in the code and it gives ArrayIndexOutOfBoundsException.I'm not able to …

Member Avatar for Starstreak
0
170
Member Avatar for Hemanth.Satkuri

FIRST: String str = queryTextArea.getText(); final JTextArea textArea = new JTextArea(); textArea.setFont(new Font("Sans-Serif", Font.PLAIN, 12)); textArea.setText(str); textArea.setCaretPosition(0); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setPreferredSize(new Dimension(350, 150)); int res = JOptionPane.showConfirmDialog(null,scrollPane,"Query", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); System.out.println( "showInputDialog: " + res ); if(res==0) queryTextArea.setText(textArea.getText()); Using this I'm unable to resize the document-modal SECOND: String str …

Member Avatar for NormR1
0
707
Member Avatar for John DB

How can I terminate resources in a safe way when JFrame is about to close? - If I put terminate() in the a finally block it runs before windowClosing(). - If I put terminate in windowClosing() it can't be accessed from an inner class. I am aware that I shouldn't …

Member Avatar for John DB
0
191
Member Avatar for dantheman4

public static void sumOfSquareRoots() { Scanner scan = new Scanner( System.in ); double value; // read in a double System.out.print ("Enter a double:"); value = scan.nextDouble(); // calculate its square root double result = Math.sqrt( value ); // write out the result System.out.println("square root of your number is " + …

Member Avatar for delta_frost
0
2K
Member Avatar for johnalternate

Hi friends , i have a assignmentin my course Information Retrival and text mining. I have to develop a search engine in java. i am reading data from 31103 files and have to do some processing in each... but i am stuck in a logical error, i.e in the loop …

Member Avatar for NormR1
0
101
Member Avatar for sk8ergirl

Hello ^^ I asked the user for location code and then I need to find if location code is in the array of LOCATIONS and display this result "Region: ! | Location: ! |City: ! " in a method call format .. where the ! marks are the actual values …

Member Avatar for NormR1
0
269
Member Avatar for io.caraballo

Hi, Im a noob programmer, Ive done some small programs. Im looking for a guide that may give me tips and guideline for things to do a plan before starting to write your code.

Member Avatar for JamesCherrill
0
237
Member Avatar for iEpic

I'ma noob and need some help from the pros. For school I gotta make a program to convert numbers into roman numerals 1-10 and return an error if its not 1-10. Got it all pretty much figured out but I want to know how to have it where if someone …

Member Avatar for JamesCherrill
0
215
Member Avatar for Aia

Self-teaching Java, I am following a video tutorial about simple windows. Encountered a warning error using the example provided in the tutorial. Here's the piece of code. [CODE=Java]import java.awt.Frame; import java.awt.Label; import java.awt.AWTEvent; import java.awt.event.WindowEvent; public class HowdyByeWindow extends Frame { public static void main( String[] args ) { new …

Member Avatar for flash901
0
923
Member Avatar for mikewyatt

I am trying to get my Java DB setup correctly with NetBeans 7.2 to start building databases. When I leftclick on Java DB every option is greyed out except for Properties. There is no sample databases or anything else when selected, a popup appears requesting Java DB Installation: Database Location: …

Member Avatar for mikewyatt
0
125
Member Avatar for bigredaltoid

package mypackage; import java.util.Scanner; public class twinPrimes { public static void main(String[] args){ int userNum = 0; int attemptCount = 0; while (userNum < 3){ System.out.println("Please enter an integer greather than three."); Scanner in = new Scanner(System.in); userNum = in.nextInt(); attemptCount++; if (attemptCount == 3){ System.exit(1); } } int count …

Member Avatar for bigredaltoid
0
158
Member Avatar for brindelsnatch

This is my first post in the Dani community. I am brand new to java, i'm supossed to make a Java Program to randomize integers from 1-50 into a 4rows by 5collumns array. Display the randomize numbers, then sort and display. Thank you

Member Avatar for Dani
0
37
Member Avatar for venkyb47

I am unable to send a string from php page to java script page. I am storing a string in a php variable and I want to send this value to java script page on image icon click. Here is the source code: timetrack.php $activityid = $getResult->fields('ACTIVITY_ID'); // Now consider …

Member Avatar for venkyb47
0
340
Member Avatar for trishtren

Hello, iv looked around google and have found it is possible to put an applet into a jframe. The problem i am having is that my applet is to be hosted online, what i want is to take the applet that is online and display it from a swing or …

Member Avatar for NormR1
0
227
Member Avatar for techxaidz

PROBLEM: > Using a text editor, create a file that contains a list of five 4-digit account numbers. Read in each account number, and alter it to add a dash and a check digit, which is calculated by taking the remainder when the original number is divided by 7. Write …

Member Avatar for stultuske
0
209
Member Avatar for rvijaya

Hi, this is my basic program for an assignment but I can't figure out why I am not getting the desired output for the grade printed and why there is a repetition of the Enter Student Name at the end before the program loops again. I have also included a …

Member Avatar for rvijaya
0
141
Member Avatar for rahul.ch

I noticed that when equals() is used to compare between two String objects it works fine. But when I compare two StringBuffer objects or two StringBuilder objects or mix of String and Builder and Buffer, equals() doesn't work even though I give same string value to the two objects being …

Member Avatar for rahul.ch
0
318
Member Avatar for Babyblues

Ok so here is what I have and I am stuck. It is not recognizing whether a number is even or odd. So where do I need to put the remainder operator so that it will recognize if a number is even or odd? import javax.swing.JOptionPane; // program uses JOptionPane …

Member Avatar for stultuske
0
194
Member Avatar for Pankti Shah

I am making a project where i have a rotating and moving 3d cube and on click of any face of cube, that face should be enlarged. All the six faces of cube should have different images. I searched a lot but doesn't get any working. Any help regarding this …

0
110
Member Avatar for sonu611

Hi all, I was looking for a way to execute windows batch file from java code, and I was able to do this with the following code. [CODE] Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("cmd /C " + "path" +exec.bat"); [/CODE] The batch file refers to some other files …

Member Avatar for shahbaz07dbit
1
1K
Member Avatar for rahul.ch

import java.util.*; class SampleA { } class SampleB extends SampleA{ } class SampleC extends SampleA{ } class VectorDemo { public static void main(String r[]) { Vector<SampleA> v = new Vector<SampleA>(); v.add(new SampleB()); v.add(new SampleC()); SampleC rect = v.get(2); } } The output says "Incompatible types. Found SampleA, required SampleC. SampleC …

Member Avatar for rahul.ch
0
225
Member Avatar for dantheman4

public static void total() { Scanner s = new Scanner("five six seven eight"); int num= 0; for(int i=0; i < s.length; i++) { if(s.charAt(i).equals("a") || s.charAt(i).equals("b") num++; } System.out.print(num); } public static void main(String[] args) { total(); } > What am I doing wrong ?

Member Avatar for Nutster
0
145
Member Avatar for london-G

Hello, I have 3 combobox and I want to find them in my table "class" and retrieve the ID. I am currently having trouble with the following code: public void retrieveClass(String time,String stage, String teacher){ Connection con = null; ResultSet rs = null; java.sql.PreparedStatement st = null; Properties conProps = …

Member Avatar for london-G
0
212
Member Avatar for mikias.kidane.9

I am having a problem with arrays.... for this assignment i can not use Arraylist... I only be able to use array of string. here is my problem. I am asking the user to enter words with in 1 minute ... when the time is up ..i need to print …

Member Avatar for NormR1
0
247

The End.