32,199 Topics
| |
I m trying to pass a 10.10 value to double and it takes 10.1 instead of this? Any solution. | |
Here is my code: [CODE]class Catandmouse { public void CatAndMouse() { Animal cat = new Animal(); Animal mouse = new Animal(); int mouseCaught = (int) (Math.random() * 10); cat.CatchMouse(); int catgetsit = 0; if ( mouseCaught == cat.number ) { System.out.println("The cat caught the mouse!"); } else { System.out.println("The mouse … | |
How to print this series using loop 1,1,2,3,5,8,11,19,30,49........... | |
well basically i have this code working to display distance to nearest station and the station name but i want it to show what line the station nearest is located on i've tried to figure it out but just dont seem to be getting anywhere with it the code (including … | |
Hey everyone, i need a little help with searching a string and putting that date into another string. ex: [CODE] String com = ""; String mystring = "sometext here: !com shutdown"; // Magic happens System.out.println(com); // Output: "shutdown" [/CODE] "!com" is the constant to search for, shutdown is variable. | |
Hey there. How do i stop this damn computer form automatically filling in my second Qoute when i make the first one " and then i have to press space for there just to appear one. It messes me around sooo badly with my programming. it does that wiht quotes, … | |
Hy I want to validate expression as such: [code]AO:10 EM:1 IO:102 AO:SA EM:SA,AKA,LLMN[/code] so on... I'm noe to Regex and i came out with the following function: [CODE] public void checkFormat(String line) { String expression = "^[ACEILMNOU.]{2}+\\B[:]{1}+\\w{2,4}+"; Pattern subscriptionExpretion = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = subscriptionExpretion.matcher(line); if(matcher.matches()) { System.out.println("matches " … | |
i am having problem in developing a project based on bluetooth. i am not able to import the package javax.microedition.lcdui.*.it showing error that package not exits. please tell me what to do... | |
i got this code form the internet where it can delete a file.but when i tried to use it n my own java program it does not work anymore.it always returns 'Could not delete file'. ~this code is for my method delete[CODE]public void delete(String file, String lineToRemove) throws IOException{ try … | |
For a (homework) project, I have a class ComplexNumber that needs to be printed. I have a number of operations that can be done on objects of the class (addition, subtraction, multiplication, division). Each operation returns a new ComplexNumber to be printed. How exactly do I print this? Do I … | |
I am new to programming, so please accept my apologies if this question is simple. My teacher wants us to create a method that searches a stack for the name that occurs most often and returns it for example : If I have these names in my stack: Tiger Woods, … | |
Hello to you all! I am relatively new to java but I am creating a project in java using net beans 7.1 where I create a mysql database that holds the data of a web service. Unfortunately, while my code runs fine, it shows at the beginning the following two … | |
[CODE] proiect2 package; import java.io. *; public class String { static BufferedReader buffer = new BufferedReader (new InputStreamReader (System.in)); static String string = null; public static void main () throws IOException, NumberFormatException { System.out.println ("Enter string:"); String string = buffer.readLine (); while (sir.length () == 0) { System.out.println ("The string … | |
Can two classes exist in a single .java file? Reply quick, please. | |
Hey guys. I am creating an ordered list using an array. Not an ArrayList or anything else. I can not figure out how to get all of the data from the OrderedList constructor to carry through to my "insert" method. Therefore, when I am checking if "count == 0" it … | |
Hi, is there anybody here knows how to store arrays in a text file? let's say the user inputs the id, name, and address and stores it on a text file then shows its output.. ex. 245656, John, 6534 Japan, Male. something like that. or anyone have a similar program … | |
Hi, basically ive been trying to write code to work out where the nearest station for a person is based on their current location. I did have it working to display nearest station name and distance from that station but something went wrong I must have accidently deleted something or … | |
Hy, I have to write a program witch recognizes the extension of the file it gets as argument after that it has to validate the file line by line. A file should look like this: ex: Name, Age, Email, OptionalField1, OptionalField2 Anna, 22, [email]anna@smting.com[/email], completed Mark, 24, [email]mark@smting.com[/email], completed completed … | |
Hi all, This is also similar to web browsers which use the codes, &d for date, and &l&f&r for document name, etc. I would like to start the page number for 165, for example, is there a code to do this? (For within the print preview/page setup area). I've already … | |
Hello! I'm trying to write a program that will eventually carry out matrix multiplication (by another matrix and by a vector) among a few other methods for a homework assignment. However, the assignment says we first need to write a default constructor that creates the 3x3 Identity Matrix. I'm not … | |
Hi, I am doing an exercise of Head First Java Pool puzzle. I tried many times and finally got the output required but I am still not fully understand that how program produced that output. The code for Pool Puzzle is as under: [Code] class Echo { int count = … | |
Hi all, when I use break statement like following it doesn't show any error [CODE] String o="": o = o + 2; z: for(int x = 3; x < 8; x++) { if(x==4) break; if(x==6) break z; o = o + x; [/CODE] but when I interchange the label(z) position … | |
Hi, We have Unicode database and I have generated the i-reports and called them from java in my application but it gets opened my regional language fonts i.e (MARATHI) fonts are not shown properly by adobe reader in PDF format can anyone help me how to get Unicode support for … | |
[CODE]package test; import java.util.*; import sun.security.krb5.internal.UDPClient; import java.net.*; public class CMD { public static void main(String[] args) throws UnknownHostException, SocketException { DatagramSocket sock = new DatagramSocket (); Scanner keyboard = new Scanner(System.in); String fisrtarg=null; // System.out.println("Enter CMD"); // fisrtarg = keyboard.nextLine(); if (args.length > 0) {//this is important if no … | |
Hi I am currently doing a project on the aglets. I have a problem in the installation of tahiti server. I have downloaded the asdk 1.0.3 and set the environment variables. Then i run the agletsd (tahiti server file) as administrator and followed the initial steps. Then a command prompt … | |
[CODE]public JLabel SetImage(String path) throws IOException { ImageIcon myPicture = new ImageIcon(path);//ImageIO.read(new File(path)); JLabel picLabel = new JLabel(); picLabel.setBounds(0, 0, 2, 2); picLabel.setIcon(myPicture); pnlImage.setLayout(null); pnlImage.add(picLabel); pnlImage.repaint(); pnlImage.revalidate(); return picLabel; } try { String Ref = txtRef.getText(); SetImage(); JLabel label = new JLabel(); label = SetImage("C:\\Users\\Documents"); App\\ImagesDoc_001.jpg"); pnlImage.setLayout(null); pnlImage.add(label); pnlImage.repaint(); pnlImage.revalidate(); … | |
Hi all I'm wondering how i add Action listener to this Button It has no text, just an image, from an ImageIcon I tried I3 for the action listener but i doesant work [CODE] ImageIcon I3; I3 = new ImageIcon ("carrier.gif"); J1 = new JButton (I3); J1.addActionListener (this); J1.setBounds (420, … | |
| Hi guys, I was doing my project when i came across this error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:686) at Screen.screenRunner(Screen.java:84) at Screen.main(Screen.java:90) I am also having problems getting my program to accept user input(height and width). [CODE]import java.util.Scanner; public class Screen { … |
hey there. Im using Netbeans. i have a form where there is a button edit. when i press it, other form opens, and the selected item on the previous page has to be edited in the databse. So bottom line, i have to get a String / int that i … | |
hi What is the difference between in JFrame and JWindow? If I want to develop a a desktop application either I have to use JWindow or JFrame. |
The End.