Class

Java Class

Deals

Advertise on this page

Welcome to Java Class News

Welcome to Java Class Questions and Answers



Open Question: Getting Error messages while trying to log on Chat rooms?

Dear All I'm getting these error messages while trying to log on Java based chat rooms from my desk top computer but its ok with my laptop so I did checked every thing I could so any one can help me why its happening and how to rectify? Java Plug-in 1.6.0_14 Using JRE version 1.6.0_14-b08 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\Prakash Bhattarai ---------------------------------------------------- c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to <n> ---------------------------------------------------- load: class Client.class not found. java.lang.ClassNotFoundException: Client.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.net.SocketException: Invalid argument: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.HttpURLConnection.getResponseCode(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 7 more Exception: java.lang.ClassNotFoundException: Client.class load: class NPTime.class not found. java.lang.ClassNotFoundException: NPTime.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.net.SocketException: Invalid argument: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.HttpURLConnection.getResponseCode(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 7 more Exception: java.lang.ClassNotFoundException: NPTime.class more

Voting Question: Hi. Is anyone able to tell whether a Java abstract class can inherit from a concrete class?

 more

Resolved Question: Simple Java Class Question?

hi, I normally code using C++ but I'm trying to improve my java. I've written this simple code but i get confusing output. First I've written a class called bike, here is the code: public class Bike { int speed; int gear; public Bike(){ int speed = 0; int gear = 1; } void speedUp() { speed += 10; } } Then I wrote a class called BikeShop as follows: public class BikeShop{ public static void main(String[] arguments) { Bike bike1 = new Bike(); Bike bike2 = new Bike(); bike1.speedUp(); System.out.println("Bike1's speed is " + bike1.speed + " in gear " + bike1.gear); System.out.println("Bike2's speed is " + bike2.speed + " in gear " + bike2.gear); } } now the output i get is: Bike1's speed is 10 in gear 0 Bike2's speed is 0 in gear 0 so it looks like the speedUp method is working but why is it saying gear 0? does anyone else get the same using another compiler (i'm using one called PhysEdit which is quite old)? Can you see where I've gone wrong? please help!Thanks guys, works now, schoolboy error more

Resolved Question: Java error? Don't know why? Help?

I was doing a little bit of programming at home, and I got an error for trying to parse a string from a text box. Here's the code: public void actionPerformed(ActionEvent event) { String eventName = event.getActionCommand(); JComboBox comboBox = (JComboBox)event.getSource(); String formula = (String)comboBox.getSelectedItem(); double answer; int number; getNumber.getText(); number = (Integer.parseInt(getNumber)); if (formula == "inches to centimeters") { conversionFormula.setText("1 inch = 2.54 centimeters"); } else if (formula == "feet to meters") { conversionFormula.setText("1 foot = 0.3048 meters"); } else if (formula == "gallons to liters") { conversionFormula.setText("1 gallon = 4.5461 liters"); } else if (formula == "pounds to kilograms") { conversionFormula.setText("1 pound = 0.4536 kilograms"); } if (eventName == "Convert" && formula == "inches to centimeters") { answer = number * 2.54; finalAnswer.setText("" + answer); } } and this is the error message: MetricConversion\src\MetricConversion.java:81: cannot find symbol symbol : method parseInt(javax.swing.JTextField) location: class java.lang.Integer number = (Integer.parseInt(getNumber)); ^ 1 error Process completed. I don't know why I'm getting this, and I'ts frustrating. Do I have to impot anything else? I have already imported javax.swing.*; , java.awt.*; and java.awt.event.*; Thanks PS. the ^ error arrow is supposed to be under the (.) instead of number more

Voting Question: pjirc Java problem Not Connecting?

i have just downloaded the newest v of pjirc and for some reason i am getting this error Unable to connect : java.net.ConnectException : Connection refused: connect i have uploaded every file to my server i have asked mates to go to the site but it says the same i have even used a proxy and i am getting this log Java Plug-in 1.6.0_13 Using JRE version 1.6.0_13 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\Nick ---------------------------------------------------- c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to <n> ---------------------------------------------------- load: class IRCApplet.class not found. java.lang.ClassNotFoundException: IRCApplet.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.IOException: open HTTP connection failed:http://www.webproxy.bz/IRCApplet/class.class at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 7 more Exception: java.lang.ClassNotFoundException: IRCApplet.class load: class IRCApplet.class not found. java.lang.ClassNotFoundException: IRCApplet.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.IOException: open HTTP connection failed:http://www.webproxy.bz/IRCApplet/class.class at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 7 more Exception: java.lang.ClassNotFoundException: IRCApplet.class can some 1 help me i realy like this chat room but theres no videos or anything any were showing you how to set 1 up my email is daviesboi18@hotmail.com if any 1 will help seen has i cant replie to this more

Resolved Question: Java: i have created a class, in which i have a button. how can i refer to to that button from another class?

(actually, my original class extends class 'Frame'. in that, i have a button object. now, i wish to change the location of that button inside another class. please let me know how to refer to that button object inside this class for changing its location?) more

Resolved Question: i seem to be having problems with my computer (hijack this log included)?

so yeah ive noticed my computer has not been running certain programs like speedup my pc 2009 and that i have to use the main power button which i use to start up, to turn the computer off i dont know why the start then turn off dont work its really awqward , so please read this hijack log to see if theres a virus or anything Logfile of Trend Micro HijackThis v2.0.2 Scan saved at 23:31:13, on 04/06/2009 Platform: Windows XP SP3 (WinNT 5.01.2600) MSIE: Internet Explorer v8.00 (8.00.6001.18372) Boot mode: Normal Running processes: C:\WINDOWS\System32\smss.exe C:\WINDOWS\system32\winlogon.exe C:\WINDOWS\system32\services.exe C:\WINDOWS\system32\lsass.exe C:\WINDOWS\system32\nvsvc32.exe C:\WINDOWS\system32\svchost.exe C:\WINDOWS\System32\svchost.exe C:\WINDOWS\system32\svchost.exe C:\WINDOWS\Explorer.EXE C:\WINDOWS\system32\spoolsv.exe C:\Program Files\Avira\AntiVir Desktop\sched.exe C:\WINDOWS\system32\ctfmon.exe C:\Program Files\Analog Devices\Core\smax4pnp.exe C:\Program Files\Analog Devices\SoundMAX\Smax4.exe C:\Program Files\Common Files\AOL\1157974210\ee\AOLSoftware.exe C:\Program Files\Avira\AntiVir Desktop\avguard.exe C:\Program Files\Search Settings\SearchSettings.exe C:\Program Files\Common Files\Apple\Mobile Device Support\bin\AppleMobileDeviceService.exe C:\Program Files\Canon\MyPrinter\BJMyPrt.exe C:\WINDOWS\ATKKBService.exe C:\Program Files\MagicMus\MulMouse.exe C:\Program Files\Java\jre6\bin\jusched.exe C:\Program Files\Bonjour\mDNSResponder.exe C:\Program Files\SimpleCenter\bin\win\sclauncher.exe C:\Program Files\QuickTime\QTTask.exe C:\Program Files\iTunes\iTunesHelper.exe C:\Program Files\Kontiki\KHost.exe C:\Program Files\SlySoft\CloneCD\CloneCDTray.exe C:\WINDOWS\system32\RUNDLL32.EXE C:\Program Files\MagicMus\MagicWl.exe C:\Program Files\HiYo\bin\HiYo.exe C:\Program Files\Spybot - Search & Destroy\TeaTimer.exe C:\Program Files\Messenger\msmsgs.exe C:\Program Files\Common Files\AOL\ACS\AOLacsd.exe C:\WINDOWS\System32\svchost.exe C:\Program Files\Java\jre6\bin\jqs.exe C:\Program Files\Kontiki\KService.exe C:\Program Files\Common Files\Nero\Nero BackItUp 4\NBService.exe C:\Program Files\Microsoft\Search Enhancement Pack\SeaPort\SeaPort.exe C:\Program Files\Alcohol Soft\Alcohol 120\StarWind\StarWindServiceAE.exe C:\WINDOWS\system32\svchost.exe C:\WINDOWS\system32\UAService7.exe C:\PROGRA~1\SPEEDB~1\VideoAcceleratorService.exe C:\WINDOWS\wanmpsvc.exe C:\WINDOWS\system32\SearchIndexer.exe C:\Program Files\Avira\AntiVir Desktop\AVWEBGRD.EXE C:\Program Files\Uniblue\RegistryBooster 2\RegistryBooster.exe C:\Program Files\Siber Systems\AI RoboForm\RoboTaskBarIcon.exe C:\Program Files\DAEMON Tools Pro\DTProAgent.exe C:\Program Files\Logitech\SetPoint\SetPoint.exe C:\Program Files\Common Files\Logitech\khalshared\KHALMNPR.EXE C:\PROGRA~1\SPEEDB~1\VideoAcceleratorEngine.exe C:\Program Files\iPod\bin\iPodService.exe C:\Program Files\Avira\AntiVir Desktop\avmailc.exe C:\Program Files\Avira\AntiVir Desktop\avscan.exe C:\Program Files\Mozilla Firefox 3.1 Beta 2\firefox.exe C:\WINDOWS\system32\SearchProtocolHost.exe C:\Program Files\Trend Micro\HijackThis\HijackThis.exe R0 - HKCU\Software\Microsoft\Internet Explorer\Main,Start Page = http://mystart.hiyo.com/ R1 - HKLM\Software\Microsoft\Internet Explorer\Main,Default_Page_URL = http://go.microsoft.com/fwlink/?LinkId=69157 R1 - HKLM\Software\Microsoft\Internet Explorer\Main,Default_Search_URL = http://go.microsoft.com/fwlink/?LinkId=54896 R0 - HKLM\Software\Microsoft\Internet Explorer\Main,Start Page = http://go.microsoft.com/fwlink/?LinkId=69157 R1 - HKCU\Software\Microsoft\Internet Explorer\SearchURL,(Default) = http://search.aol.co.uk/web?isinit=true&query=%s R1 - HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings,AutoConfigURL = http://localhost:9415/tudouva.pac R1 - HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings,ProxyOverride = local R0 - HKCU\Software\Microsoft\Internet Explorer\Toolbar,LinksFolderName = R3 - URLSearchHook: (no name) - {E312764E-7706-43F1-8DAB-FCDD2B1E416D} - (no file) O1 - Hosts: 66.98.148.65 auto.search.msn.es O2 - BHO: (no name) - Software - (no file) O2 - BHO: (no name) - {2E0AC6C8-FEE8-4356-BF7B-2E62CA2125A6} - (no file) O2 - BHO: flashget urlcatch - {2F364306-AA45-47B5-9F9D-39A8B94E7EF7} - C:\Program Files\FlashGet\jccatch.dll O2 - BHO: Spybot-S&D IE Protection - {53707962-6F74-2D53-2644-206D7942484F} - C:\Program Files\Spybot - Search & Destroy\SDHelper.dll O2 - BHO: (no name) - {5C255C8A-E604-49b4-9D64-90988571CECB} - (no file) O2 - BHO: (no name) - {5C2CFABF-8413-4882-BCEC-3EBB8A3E624A} - (no file) O2 - BHO: DealioBHO Class - {6A87B991-A31F-4130-AE72-6D0C294BF082} - (no file) O2 - BHO: Search Helper - {6EBF7485-159F-4bff-A14F-B9E3AAC4465B} - C:\Program Files\Microsoft\Search Enhancement Pack\Search Helper\SEPsearchhelperie.dll O2 - BHO: RoboForm - {724d43a9-0d85-11d4-9908-00400523e39a} - C:\Program Files\S more

Resolved Question: Ubuntu + Tomcat5.5 + MySQL connector driver?

Hello, I've been spending the whole day on a CLASSPATH problem with my Tomcat5.5 install on ubuntu : I've installed: apt-get install sun-java6-jdk sun-java6-jre tomcat5.5 libmysql-java I set : TOMCAT5_SECURITY=no in /etc/default/tomcat5.5 because of access right errors with Birt (the reporting tool I intend to run) I expected the mysql-connector JAR driver installed thanks to libmysql-java, but I get the following trace in catalina.log : SEVERE: DriverClassLoader failed to load class: com.mysql.jdbc.Driver java.lang.ClassNotFoundException: com.mysql.jdbc.Driver I'm pretty sure I didn't put the driver in the right folder, but I cannot figure out where to put it ! Wherever I put the mysql-connector JAR file, I get the same error. If I look at the default installed driver, I see : -rw-r--r-- 1 root root 679777 2008-07-31 14:53 /usr/share/java/mysql-connector-java-5.1.6.jar lrwxrwxrwx 1 root root 30 2009-06-02 22:39 /usr/share/java/mysql-connector-java.jar -> mysql-connector-java-5.1.6.jar Thanks in advance for your help more

Resolved Question: Converting-feet&Inches to Centimeters-JAVA?

This is a Program which converts the feet & inches into Centimeters,i've written the program but i need to add exceptions for a nondigit number & for a negative number. can someone at least show me how to add one of the exceptions & i will try the other as the ones I'm trying don't seem to work!! thanks! will appreciate ur help!! Here is the Code: import java.util.*; public class Exceptions { static Scanner console= new Scanner(System.in); static final double CENTIMETERS_PER_INCH = 2.54; static final double INCHES_PER_FOOT = 12; public static void main(String[] args) { int feet; int inches; int totalInches; double centimeters; System.out.print("Enter feet: "); feet = console.nextInt(); System.out.println(); System.out.print("Enter inches: "); inches = console.nextInt(); System.out.println(); totalInches = (int) (INCHES_PER_FOOT * feet + inches); System.out.println(); System.out.println("The total number of inches = " + totalInches); centimeters = totalInches * CENTIMETERS_PER_INCH; System.out.println("The number of centimeters = " + centimeters); } } more

Resolved Question: Write a class definition to represent such payroll details?

I am a student in Middlesex unversity in LONDON,every week at University my class are set a set of tasks to complete for the next week. However, this week it snowed very heavily and the lecture for my Java module was cancelled, so I didn't receive any help on how to solve this weeks' tasks. So this is an SOS to those out there who know what they're doing. more

Voting Question: Write a method to accept 10 date objects and store them in the array? This question is about JAVA?

I am a student in Middlesex unversity in LONDON,every week at University my class are set a set of tasks to complete for the next week. However, this week it snowed very heavily and the lecture for my Java module was cancelled, so I didn't receive any help on how to solve this weeks' tasks. So this is an SOS to those out there who know what they're doing. more

Resolved Question: JAVA: How to reference things from another class?

I need to learn how to reference something from another class. More specifically, i have an array stated in one class, and i want to reference it's field from another class. Can anyone help? Thanks. more

Resolved Question: Could some1 check my answer for this (Java) im pretty sure ive got it wrong and am stuck.?

Ok here is what is asked and im stuck on (b) and (c). • A CD track is to be represented as an instance of a class called Track; each Track object will consist of the track’s title (a String) and its duration (an int representing the time in seconds). • A class called TrackList is to be defined with a single field, an ArrayList of Track object variables. • A class called CD is to be defined such that each CD object consists of the artist’s name (a String), the title of the CD (a String) together with a list of the track’s on the CD (represented by a TrackList object). (b) Give a Java definition for the field in the TrackList class. //this doesnt make much sense to me. Its asking for an arraylist of 2 different type variables in the class track, int duration and String title? How is this done? anyway I put down: private ArrayList<Track> ObjVar = new ArrayList<Track>() ; Which is my vague idea of what its asking for. (c) Write a constructor to initialise an empty TrackList object. thankyou more

Resolved Question: What is a good Variable to store a collection of Objects in Java?

A simple question. What is a good Variable to store a collection of Objects in Java IE. I have made a class to get stock information and now I want to make another object that stores that information and will add and remove the objects and info. I know I need a getter and setter but my mind has gone blank, I think its really easy but I always over complicate it in my mind. so a hint would be nice. more

Resolved Question: How to alter a default constructor in Java?

I have an assignment to do that involves altering a default constructor to take 4 arguments Have managed to get that part right but the arguments don't appear in the right order in the graphical display with tens and units appearing between op1 and op2 instead of the right order of op1, op2, tens, units. Can anyone help? My code is /** * Default constructor for objects of class FrogCalculator */ public FrogCalculator(Frog op1, Frog op2, Frog tens, Frog units) { super(); this.operand1Frog = op1; this.operand2Frog = op2; this.tensFrog = tens; this.unitsFrog = units; tensFrog.setColour(OUColour.BROWN); unitsFrog.setColour(OUColour.YELLOW); } more

Resolved Question: can some1 do this past exam Q (java)?

Could some1 do this question so I can see the flow. • A CD track is to be represented as an instance of a class called Track; each Track object will consist of the track’s title (a String) and its duration (an int representing the time in seconds). • A class called TrackList is to be defined with a single field, an ArrayList of Track object variables. • A class called CD is to be defined such that each CD object consists of the artist’s name (a String), the title of the CD (a String) together with a list of the track’s on the CD (represented by a TrackList object). (a) Give a Java definition for the Track class, containing definitions for the fields, a constructor and an accessor method for each field. (b) Give a Java definition for the field in the TrackList class. (c) Write a constructor to initialise an empty TrackList object. (d) Define a private static method for the TrackList class to convert a time in seconds (an int) into the format hrs:mins:secs (a String). (e) Write a method for the TrackList class to return the total playing time of a TrackList object as a String in the above format (use the private method you have just defined). (f) Define the fields of the CD class. (g) Define methods for the TrackList and the CD classes to return the title of the longest track thankyou more

Resolved Question: JAVA: Number for each object in a class?

I have a description of a class which i need to write skeletal declarations for. If there is a bunch of objects assigned to the class, and there is a number (named TNumber) assigned to each one, which is one more than that of the previous object (it goes up 1 for each object). What declaration would satisfy this? Thanks in advance. more

Resolved Question: How To get my java program to read the up, down and space bar keys to make different events happen?

I am pretty new to Java, I have recently learnt about public voids, So I used these to make a "Cd Player", however I want the program to read the up arrow for the "InsertCD" the down arrow for "RemoveCD" and the space bar for "PlayCD" my code is as followed... public class CdPlayer{ public static void main(String[] args){ } boolean CDIN; public void InsertCD(){ System.out.println("Inserting CD"); CDIN = true; } public void PlayCD(){ CdPlayer Player = new CdPlayer(); if(!CDIN){ Player.CDNOT(); } else { Player.CDIS(); } } public void RemoveCD(){ System.out.println("CD has been removed"); CDIN = false; } public void CDNOT(){ System.out.println("There is no CD found"); } public void CDIS(){ System.out.println("CD found, playing CD"); } } I am planning to make it better, but first I need to know this, so please tell me if I have to import anything and the code to put in the main to make each event happen, thank you ^.^ more

Resolved Question: just check im gettin this right (Simple Java)?

ok I have this java data item: a field of data type Address and name street. now I have to declare it. It would be private Address street; wouldnt it? and that would be under the class name not in the main method? I just need this checked. ty more

Resolved Question: Java Help..5Stars will be given to best answer?

Hey everyone i'm currently learning java. I'm a beginner. So basically i don't know much. I am studying java and i am on a question that ask the following 2. add a constuctor to your car class that does not take any arguments. Have this constructor set the initial velocity of the car to be 55. add the following line of code to this constructor System.out.println("Inside default constructor"); 3. Add a second constructor to your car class that takes in an integer. Have this interger be the inital velocity of the car. add the following line of code to this constructor. System.out.println("Inside other constructor"); unfortunately the book that am readin which is provided from the course am doing does not explain stuff good enough. My tutor is really sh*t to be honest. So its down to you guys to help me out What does it mean by (add a constructor to your car class that does not take any arguemnts)? also what does instantiate mean?? if you could answer all questions i will be sure to give you 5star rating here is my code for my Car program public class Car { int Velocity; int brake; int stop; //constructor public Car() { Velocity=55; System.out.println("Inside the default constructor"); } public void accelerate() { Velocity = Velocity + 10; brake = brake -20; stop = stop -10; } public void brake() { //reduce velocity by 20 } public void stop() { //set velocity to 0 } int getVelocity() { return Velocity; } public void setVelocity(int v) { Velocity = v; } //constructor two public Car(int velocity) { Velocity = 55; System.out.println("Inside other constructor"); } } more

Voting Question: codes 4 g600 look no longer?

G600 Unlock Method 1-Turn on the phone without sim card . 2-Pull off the battery cover and insert any non-accepted sim card (without turning off the handset) 3-Do full reset *2767*3855# , phone will reboot and goes to Menu . 4-Customize Sp-lock code *7465625*638*00000000*00000000# 5-Unlock your phone with new SP code #7465625*638*00000000# 6-Enjoy G600 unlocked If it works for you please use Buy it Now to donate towards costs. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Bonus... Samsung Secret Codes for advanced users only *#1111# S/W Version *#1234# Firmware Version *#2222# H/W Version *#8999*8376263# All Versions Together *#8999*8378# Test Menu *#4777*8665# GPSR Tool *#8999*523# LCD Brightness *#8999*377# Error Menu *#8999*327# EEP Menu *#8999*3825523# Don't Know. *#8999*667# Debug Mode *#92782# PhoneModel (Wap) #*5737425# JAVA Mode *#2255# Call List *#232337# Bluetooth MAC Adress *#5282837# Java Version #*4773# Incremental Redundancy #*7752# 8 PSK uplink capability bit #*7785# Reset wakeup & RTK timer cariables/variables #*1200# ???? #*7200# Tone Generator Mute #*3888# BLUETOOTH Test mode #*#8999*324# ?? #*7828# Task screen #*5111# ?? #*#8377466# S/W Version & H/W Version #*2562# Restarts Phone #*2565# No Blocking? General Defense. #*3353# General Defense, Code Erased. #*3837# Phone Hangs on White screen #*3849# Restarts Phone #*3851# Restarts Phone #*3876# Restarts Phone #*7222# Operation Typ: (Class C GSM) #*7224# !!! ERROR !!! #*7252# Operation Typ: (Class B GPRS) #*7271# CMD: (Not Available) #*7274# CMD: (Not Available) #*7337# Restarts Phone (Resets Wap Settings) #*2787# CRTP ON/OFF #*2886# AutoAnswer ON/OFF #*3737# L1 AFC #*5133# L1 HO Data #*7288# GPRS Detached/Attached #*7287# GPRS Attached #*7666# White Screen #*7693# Sleep Deactivate/Activate #*7284# L1 HO Data #*2256# Calibration info? (For CMD set DEBUGAUTONOMY in cihard.opt) #*2286# Databattery #*2527# GPRS switching set to (Class 4, 8, 9, 10) #*2679# Copycat feature Activa/Deactivate #*3940# External looptest 9600 bps #*4263# Handsfree mode Activate/Deactivate #*4700# Please use function 2637 #*7352# BVMC Reg value (LOW_SWTOFF, NOMINAL_SWTOFF) #*2558# Time ON #*3370# Same as 4700 #*3941# External looptest 115200 bps #*5176# L1 Sleep #*7462# SIM Phase #*7983# Voltage/Freq #*7986# Voltage #*8466# Old Time #*2255# Call Failed #*5187# L1C2G trace Activate/Deactivate #*5376# DELETE ALL SMS!!!! #*6837# Official Software Version: (0003000016000702) #*7524# KCGPRS: (FF FF FF FF FF FF FF FF 07) #*7562# LOCI GPRS: (FF FF FF FF FF FF FF FF FF FF FF FE FF 01) #*2337# Permanent Registration Beep #*2474# Charging Duration #*2834# Audio Path (Handsfree) #*3270# DCS Support Activate/Deactivate #*3282# Data Activate/Deactivate #*3476# EGSM Activate/Deactivate #*3676# FORMAT FLASH VOLUME!!! #*4760# GSM Activate/Deactivate #*4864# White Screen #*5171# L1P1 #*5172# L1P2 #*5173# L1P3 #*7326# Accessory #*7683# Sleep variable #*8465# Time in L1 #*2252# Current CAL #*2836# AVDDSS Management Activate/Deactivate #*3877# Dump of SPY trace #*7728# RSAV #*2677# Same as 4700 #*3797# Blinks 3D030300 in RED #*3728# Time 2 Decod #*3725# B4 last off #*7372# Resetting the time to DPB variables #*7732# Packet flow context bit Activate/Deactivate #*6833# New uplink establishment Activate/Deactivate #*3273# EGPRS multislot (Class 4, 8, 9, 10) #*7722# RLC bitmap compression Activate/Deactivate #*2351# Blinks 1347E201 in RED #*4472# Hysteresis of serving cell: 3 dB #*2775# Switch to 2 inner speaker #*9270# Force WBS #*7878# FirstStartup (0=NO, 1=YES) #*3757# DSL UART speed set to (LOW, HIGH) #*8726# Switches USBACM to Normal #*8724# Switches USBACM to Generator mode #*8727# Switches USBACM to Slink mode #*8725# Switches USBACM to Loop-back mode #*3838# Blinks 3D030300 in RED #*2077# GPRS Switch #*2027# GPRS Switch #*0227# GPRS Switch #*0277# GPRS Switch #*22671# AMR REC START #*22672# Stop AMR REC (File name: /a/multimedia/sounds/voice list/ENGMODE.amr) #*22673# Pause REC #*22674# Resume REC #*22675# AMR Playback #*22676# AMR Stop Play #*22677# Pause Play #*22678# Resume Play #*77261# PCM Rec Req #*77262# Stop PCM Rec #*77263# PCM Playback #*77264# PCM Stop Play #*2872# CNT *#8999*283# ??? #*22679# AMR Get Time *288666# ??? *2886633# ??? *#8999*364# Watchdog ON/OFF #*8370# Tfs4.0 Test 0 #*8371# Tfs4.0 Test 1 #*8372# Tfs4.0 Test 2 #*8373# Tfs4.0 Test 3 #*8374# Tfs4.0 Test 4 #*8375# Tfs4.0 Test 5 #*8376# Tfs4.0 Test 6 #*8377# Tfs4.0 Test 7 #*8378# Tfs4.0 Test 8 #*8379# Tfs4.0 Test 9 #837837# error=... #*36245# Turns Email TestMenu on. *2767*22236245# Email EPP set (....)! *2767*837836245# Email Test Account! *2767*29536245# Email Test2 Account! *2767*0 more

Resolved Question: java help anyone please?

hey i am studying a java course for the sun certified certificate and am on a question where it ask me to invoke the square method() a couple of times to verify it is working properly anyway i keep getting compile errors here is my two codes public class MyMath { public static long square(int a) { return a * a; } } public class Squares { { MyMath.square(12); } System.out.println(MyMath.square); } could someone help me out please am abeginnerr and ihaven'tt learnt that much yet. I've just started learning about staticvariabless so if someone could give me a answer id understand due to my knowledge that would begrate-fulll i'll also choose best answer more

Resolved Question: java question programming?

All my classes are dependent on each other, class A extends class B, class B extends class C etc.... so if one doesnt work the ones that follow dont either.. is there a way to resolve this ? thanksis there a way to get the classes to inherit things from other classes whithout extending them so there not connected so that if 1 fails the ones that follow dont more

Voting Question: Programing Java Question?

All my classes are dependent on each other, class A extends class B, class B extends class C etc.... so if one doesnt work the ones that follow dont either.. is there a way to resolve this ? thanksis there a way to get the classes to inherit things from other classes whithout extending them so there not connected so that if 1 fails the ones that follow dont more

Resolved Question: How to connect between JAVA code and HTML form pages (JSP)?

I make a website, but i wrote at first its JAVA classes (about 10 classes) and i want to connect them to HTML, so i can use input in HTML form to use in JAVA code, how can i do that using JSP or any useful technique? more

Voting Question: how do you set the preferred size of a jlabel in java?

class Cell extends JLabel { int r; int c; cellGrid grid; public Cell(cellGrid grid, int r, int c) { super(); Border border = LineBorder.createBlackLineBorder(); this.setBorder(border); this.setBackground(Color.white); this.setOpaque(true); this.setPreferredSize(new Dimension (20,10)); this.grid = grid; this.r = r; this.c = c; } } this is what i have so far but the size is not changing!basically im creating a spreadsheet type application in java and i have another class (shown below) which uses class Cell in order to create a grid of cells. public cellGrid(int rows, int columns) { super(); this.rows = rows; this.columns = columns; JPanel grid = new JPanel(); grid.setLayout(new GridLayout(rows,columns)); setLayout(new BorderLayout()); this.add(grid,BorderLayout.CENTER); cell = new Cell[rows][columns]; for (int i=0; i<rows; i++) for (int j=0 ; j<columns ; j++) { cell[i][j] = new Cell(this,i,j); grid.add(cell[i][j]); } } } more

Resolved Question: Basic Java Question about programming!!!?

Question This is a question about the public and private visibility modifiers. a) Explain what the visibility modifiers public and private allow and prohibit. b) Explain what getter and setter methods are. c) Suppose that we have an instance variable int ro which we want to be read-only for code outside the class: that is, we want code outside the class to be able to find out the value of the variable, but only code inside the class should be able to modify it. You should write a variable declaration for ro, with an appropriate visibility modifier, together with a getter and a setter, both with visibility modifiers; your code should allow only the access described above. thanks alot. more

Resolved Question: A question for java programers AGAIN- SIMILAR ONE.?

Write a class, TimedInstantiation, which will have a toString method which returns a string of the following form: "I was instantiated on 12 June 2008, 35 seconds after the previous instantiation of me." if there have been previous instantiations, but if not (that is, if we are dealing with the first instantiation) it should return "I was instantiated on 12 June 2008, and I am the first instantiation." The following class might be useful: java.util.Date represents dates. Its toString() method returns the date and time in human readable form: getTime() returns a long representing the date in milliseconds, so that (d1.getTime() - d2.getTime())/1000L will be the time in seconds between dates d1 and d2. Finally, new Date() will return the current date and time. my answer is quite similar to the following: http://uk.answers.yahoo.com/question/index;_ylt=ArQHzJyhA328fDrbbKuOiz4gBgx.;_ylv=3?qid=20090428113314AAFE61l But i dont how to call the getdate() and gettime() cons/methods for every insantiation. thank , anything would be of a great help more

Resolved Question: Java Programmers Answer this!!!!!!!!!!?

Following is a questions about classes and constructors. ----------------------------- Question 5. Write a class, Limited Edition, which can be instantiated at most 100 times.If an attempt is made to instantiate it after 100 instances have been created, the constructor should throw an exception. It should also have a toString method which returns the position of the object in the sequence of instantiations. --------------------- I just don't know where to start from , it would be great if some can help me out with some coding( i also don't know how to throw the exception). i can only do the following //class class LimitedEdition{ private int instantiated; //contructor private LimitedEdition() throws Exception this.instantiated=0 thank you alot if not it would be great if you can help me out with the following question! http://uk.answers.yahoo.com/question/index;_ylt=ArQHzJyhA328fDrbbKuOiz4gBgx.;_ylv=3?qid=20090427201207AAOKIwtthanks for every one who replied more

Resolved Question: Java Question about a bank account class?

This question is about class design. The scenario will be as follows: ------------------------------------------ Bank accounts usually have an overdraft limit, but do not pay interest. The overdraft limit is not fixed, and can be changed by the account holder: however, the bank has to approve any request for changing the limit. There is a special sorts of account: a deposit account pays interest, but does not allow overdrafts at all. ------------------------------------------- Ques a) A BankAccount class should have a method void withdraw(int amount); the withdraw method should decrease the balance whenever the requested amount will leave the account in credit, or in debit by less than the overdraft limit, and otherwise it should throw an exception. Say what instance variables you will need to implement this method, and write an implementation.? I have created the following , but i dont know what instance variable i will need, and also dont know how to use the void withdraw() mehtod. /* Class definition */ public class BankAccount { /* Instant variables */ private int balance; private int overDraftLimit; private double interestRate; /* Contructor */ public BankAccount() { this.balance = 0; this.overDraftLimit = 0; this.interestRate = 0.0d; } /* Constructor */ public BankAccount(int initialBalance) { this.balance = initialBalance; this.overDraftLimit = 0; this.interestRate = 0.0d; } } ******************** I have 2 more question on the same senario of the bank account it would be great if you can answer this. http://uk.answers.yahoo.com/question/index;_ylt=Ag9XxXnFQgYEA6k.dS6fmnwhBgx.;_ylv=3?qid=20090425151346AALnzBr thank you alot.. bless you.. more

Resolved Question: I am receiving an error message when i try to load a Java based chat room?

it appears to work on other rooms ok but this one it doesnt work it comes up with an error message that says Java Plug-in 1.6.0_13 Using JRE version 1.6.0_13 Java HotSpot(TM) Client VM User home directory = C:\Users\DaVID ---------------------------------------------------- c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to <n> ---------------------------------------------------- load: class com.chatspace.Browser3x.Chat not found. java.lang.ClassNotFoundException: com.chatspace.Browser3x.Chat at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.HttpURLConnection.getResponseCode(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) ... 7 more Exception: java.lang.ClassNotFoundException: com.chatspace.Browser3x.Chat i think it may be because i updated java recently more

Resolved Question: I'm using a thread in java and was wondering how to go back to the main program after the thread ends?

im using the timer and timer task classes for the thread. I'm also having trouble with the placement of where to start the thread in the main class. more

Resolved Question: Easy 10 points for JAVA!!! Exam related question!!!!?

Pls answer/AMMEND the following question( a,b,c) pls checkout if my answer are any right>>>>>>>> Question 10 This question is about class design. The scenario will be as follows: Bank accounts usually have an overdraft limit, but do not pay interest. The overdraft limit is not fixed, and can be changed by the account holder: however, the bank has to approve any request for changing the limit. There is a special sorts of account: a deposit account pays interest, but does not allow overdrafts at all. a) A BankAccount class should have a method void withdraw(int amount); the withdraw method should decrease the balance whenever the requested amount will leave the account in credit, or in debit by less than the overdraft limit, and otherwise it should throw an exception. Say what instance variables you will need to implement this method, and write an implementation. [3 points] b) Suppose that the BankAccount class has a method void setOverdraft(int newAmount) which will set the new limit or (if the limit is not approved) throw an exception. We want to subclass BankAccount to a class DepositAccount which will never allow overdrafts: any call to setOverdraft will, therefore, throw an exception. Write an implementation of setOverdraft for DepositAccount which overrides the implementation in BankAccount and which produces the required behaviour. [3 points] c) Suppose that BankAccount has a method int getInterestRate() which (since normal accounts do not pay interest) always throws an exception: override this method in DepositAccount so that it returns the interest rate. Give declarations for any variables that you use. [3 marks] MY ANSWERS : (i am not sure if they are right) a)class BankAccount{ private void withdraw(int Amount){ int bal=getbalance(); bal=bal-Amount; if(bal<getoverdraftlimit()){ bal=bal+Amount; throw new insufficientbalException(); }return bal; } b) class DepositAccount extends BankAccount{ private void setOerdraft(int newAmount) ? ??????????????? } c)i dont know how to override methods but i can do this private int getInterestRate(){ ------------------------- } thank you The first person to answer correctly will get following : If you answer all above 3 ,, [1 extra point] total [10 points] more

Resolved Question: What am i doing wrong? Java script calender won't position in forms correctly (sits at top of screen)?

<form id="form_4" action="" method="post" target="_self" style="margin:0px; " > <div id="container" style="position:absolute; left:271px; top:261px; width:150px; height:22px; text-align:left;"> </div> <input type="Button" onclick="f_createContent()" value="Create" /> <input type="Button" onclick="f_removeContent()" value="Delete" /> <script language="JavaScript"> var N_CALNUM = 1; function f_createContent() { var e_div = f_getElement('container'); e_div.innerHTML += N_CALNUM + '. <input type="text" name="testinput' + N_CALNUM + '" value="" />' + '<img title="Open Calendar" class="tcalIcon" onclick="A_TCALS[\'myCalID' + N_CALNUM + '\'].f_toggle()" id="tcalico_myCalID' + N_CALNUM + '" src="img/cal.gif"/><br />'; new tcal ({ // form name 'formname': 'testform', // input name 'controlname': 'testinput' + N_CALNUM, // set unique ID to identify the elements 'id': 'myCalID' + N_CALNUM }); N_CALNUM++; } function f_removeContent() { var e_div = f_getElement('container'); e_div.innerHTML = ''; window.A_TCALS = null; window.A_TCALSIDX = null; N_CALNUM = 1; } </script> <div style="position:absolute; left:583px; top:622px; width:81px; height:22px; text-align:left; " > <input type="submit" id="butn_4" value="Submit" > </div> </form> more

Resolved Question: How can i watch Youtube videos?

Sometimes on youtube, i'll try to watch a video and it'll give me this message : "Hello, you either have JavaScript turned off or an old version of Adobe's Flash Player. Get the latest Flash player. Hello, you either have JavaScript turned off or an old version of Adobe's Flash Player. Get the latest Flash player. " I have already downloaded the Flash player and "runned" it, i have Java 16 class version 50.0, and my Javascript is turned on -> I have enabled Java and Javascript in tools. I am using Firefox..so what to do? Also, i don't have a little orange box at the bottom of my screen, does that mean i don't have java? more

Resolved Question: Immediate Java basic help needed alert!!!!!?

Exercise 4 - Remove blank lines Copy a file to another file removing all blank lines. -------------------- Typical Input -------------------- Here is an input text with just two blank lines. ----------------------- Typical Output ------------------------ Here is an input text with just two blank lines. i need a program that can remove all the blank lines in a file of .txt extension. i have dine the following , but i think i need to add some method... import acm.program.*; import java.util.*; import java.io.*; public class RemoveLines extends ConsoleProgram{ public void run(){ try{ String Filename=readLine("Please enter a input file name: "); BufferedReader b=new BufferedReader(new FileReader(Filename)); PrintWriter pw = new PrintWriter(new FileWriter(Filename)); String s; while((s=b.readLine())!=null){ } else{ println(s); } } b.close(); }catch (IOException e){ println("Error"); } } }pls no funny commentspls no funny commentsi need someone to help with the code.. good answer will get a bestanswer pointsthank you deonejua... thats all i wantedCan anyone help me out with this question as well.. i really appreciate your help http://uk.answers.yahoo.com/question/index;_ylt=Ar2AMVuTKPnijy5HJgm5e4QgBgx.;_ylv=3?qid=20090420101313AAluArX more

Resolved Question: assigning main class in java?

I need to assign a normal class as the main class in Netbeans. Does anyone know how to do that? thanks. more

Resolved Question: Splitting fields into parts in Java?

To be specific, i have a class with one field, policy_number, which is ten digits long. I need to use a constructor to get the year which is the first four digits of this, and the type ( from 0 to 3) which is the fifth digit. Can anybody tell me how to do this and what the constructor would look like? Thanks. more

Resolved Question: Need help with Java Class?

I have a class named Policy which has only One field named policy_number. Each policy_number has ten digits. The first four are the year, the fifth is the type (from 0 - 3) and the rest are for uniquely identifying each one. I need to include a constructor in order to create an accessor method to give the type (fifth digit) which must be in this form: public String getPolicyType() throws IllegalPolicyCodeException { } I also need to make a toString method to give the year (first four digits) which must be in this form: public int getYearOfIssue(){ } can anybody give me the code for this? Thanks. more

Resolved Question: How to separate elements in Java?

I have the field policy_number in class policy. a policy_number is ten digits long. I need to instruct by use of a constructor that the first four digits in policy_number represent a year, the fifth digit represents a type of policy, and the other five digits are for unique identification? Can anybody give me the constructor i'd need to include? I already have an accessor method named getPolicy_Type and a toString method named getYearOfIssue. Thanks. more

Resolved Question: Java Constructor in a class?

i have a java class called Policy (its not the main class). It only has one field, policy_number. The entries for this field (if its relevant) are ten digits long. I have an Accessor Method for the type of policy (the fifth digit in the policy_number), and i also have a toString method for the year the policy was issued (the first four digits of the policy_number). None of the above can change. Before the methods, i need to apply a constructor to make this work, but i can't seem to pull it off. Can anybody help? more

Resolved Question: Creating an exception class in Java?

i've created this exception class in Java. I have to keep the code in this form. I'm just wondering where i put the error message if the exception occurs in an other class where it is referred: public class IllegalPolicyCodeException extends Exception { public IllegalPolicyCodeException(String message) { super(message); } } Thanks in advance. more

Resolved Question: Constructor in a Java class?

I have a class that gives serial numbers of ten digits. The first four digits are to indicate the year, the next digit to represent a type (eg. 0 = cassette, 1= CD, 2 = DVD, 3 = Blu-Ray), with the final five digits being used simply to uniquely identify them. If i have an accessor method to give the type (from the fifth digit), and a toString method to give the year (from the first four digits), what would the constructor for it all look like? Thanks. more

Resolved Question: How do I type in information and print out from Arrays in Java?

Ok basically i'm doing a project to store details in arrays, print them out and do search here is my code for the main, it displays a menu which ask users 4 options, whether they want to add a new book, display the current list, search for a book or quit (please not I havn't finish option 3 or 4) import javax.swing.JOptionPane; public class MyProject { public static void main(String[]args) { int i= 0; Book mybooks[] = new Book[20]; int menu = Integer.parseInt(JOptionPane.showInputDialog("Press 1 to create a new entry, Press 2 to print all entries, Press 3 to search for a book, Press 4 to quit")); while (menu!=0) { if (menu ==1) //option to create new entries { mybooks[i] = new Book(); i++; } else if (menu ==2) // option to print out all the entries { for (i = 0; i <mybooks.length; i++) System.out.println(mybooks[i]); } menu = Integer.parseInt(JOptionPane.showInputDialog("Press 1 to create a new entry, Press 2 to print all entries, Press 3 to search for a book, Press 4 to quit")); }//end while System.exit(0); }//end main }//end MyProject class And this is the code for my constructor import javax.swing.JOptionPane; import java.util.*; public class Book { private int publicationYear; // instance variables private String title; private String author; public Book() {publicationYear=Integer.parseInt(JOptionPane.showInputDialog("Please enter publication year")); title=(JOptionPane.showInputDialog("Please enter book title")); author=(JOptionPane.showInputDialog("Please enter book author")); String title; String author; } public Book(int p, String t, String a) { publicationYear=p; title=t; author=a; } public void printBook() { System.out.println("Year"+"\t" +"author"+"\t"+"title"); System.out.println(publicationYear + "\t"+ author +"\t"+ title); } }//end Book class now by using the main and constructor, does anyone know how i can display my current information stored in the array taken from the constructor(i've tried to do it in the main but when it does not display what i want) more

Resolved Question: Question regarding a project I am doing in Java (storing data)?

Basically i've been given a task to make a program that stores book collections as a database Does anyone know how I can a menu to my code which will allow me to ask users to input a new entry from a keyboard print all the entries so far Quit heres my code so far import java.util.*; public class Book { private int publicationYear; // instance variables used to store book titles private String title; private String author; public Book ( int publicationYear , String title , String author ) { this.title = title; this.publicationYear = publicationYear; this.author = author; } public int getPublicationYear ( ) { return publicationYear; // a method that gets values that have been entered } public void setPublicationYear ( int publicationYear ) { this.publicationYear = publicationYear; } public String getTitle ( ) { return title; } public void setTitle ( String title ) { this.title = title; } public String getAuthor ( ) { return author; } public void setAuthor ( String author ) { this.author = author; } public static void main ( String[] args ) { Scanner scan=new Scanner(System.in); System.out.println("Please enter the details" + " then press enter"); System.out.println("publication year"); int p_publicationYear = scan.nextInt(); System.out.println("title"); String p_title = scan.next(); System.out.println("author"); String p_author = scan.next(); Book book=new Book(p_publicationYear,p_title,p_author); System.out.println("Year"+"\t" +"author"+"\t"+"title"); System.out.println("------------------"); System.out.println(book.publicationYear +book.author+"\t"+ book.title); } } more

Voting Question: Java Project Wanted !!?

hey guys, I'm doing a refresher in Java at the moment (been a while since I've been into it) and I was wondering if anyone could suggest a project (I don't care if its your assignment/tutorial work !!) that involves the three principles of OOP (abstract classes, interfaces, class extension, abstract methods etc etc) Thanks in Advance, David more

Voting Question: write a program in java that given todays date calculates tomorrows date using if and switch. i need help.?

this is what i have so far but it isnt working....can someone please edit it and help me. //objective:Performing decisions using if and switch statements import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class TomorrowsDate extends JFrame implements ActionListener { private Random randomNumber = new Random(); // random number generator private int currentDay, currentMonth, currentYear, theYears; private int tomorrowDay, tomorrowMonth, tomorrowYear, theDays, theMonths; private JTextField day, month, year; private JButton nextDay; public static void main(String[] args) { GregorianCalendar tomorrow = new GregorianCalendar(); tomorrow.roll(GregorianCalendar.DAY_OF_MONTH, 1); TomorrowsDate stage = new TomorrowsDate(); stage.setSize(260, 150); stage.createGUI(); stage.setVisible(true); } private void createGUI() { setDefaultCloseOperation(EXIT_ON_CLOSE); Container window = getContentPane(); window.setLayout(new FlowLayout()); // creates text box to show the day picked day = new JTextField("Enter todays date - day(1-31): ", 20); window.add(day); // creates text box to show the month picked month = new JTextField("Enter todays date - month(1-12): ", 20); window.add(month); // creates text box to show the year year = new JTextField("Enter todays date - year: ", 20); window.add(year); // create the next day button nextDay = new JButton("Next Day"); window.add(nextDay); nextDay.addActionListener(this); } public void actionPerformed(ActionEvent event) { currentYear = randomNumber.nextInt(3); switch (theDays) { case 1: tomorrowDay = currentDay + 1; } switch (theMonths) { case 1: tomorrowMonth = currentMonth + 1; } switch (theYears) { case 1: tomorrowYear = currentYear + 1; } JOptionPane.showMessageDialog(null,"Tomorrows date is: "+ tomorrowDay + "/" + tomorrowMonth + "/" + tomorrowYear + ".") ; } private int daysPerMonth() { //All the months with 31 days Jan, Mar, May, Jul, Aug, Oct,Dec if (currentMonth == 1 || currentMonth == 3 || currentMonth == 5 || currentMonth == 7 || currentMonth == 8 || currentMonth == 10 || currentMonth == 12) { //If we have > 31 days then tomorrow will be in next month and the day will be 1 if (tomorrowDay > 31) { tomorrowMonth = currentMonth + 1; tomorrowDay = 1; } } //All the months with 30 days Apr, June, Sept, Nov else if (currentMonth == 4 || currentMonth == 6 || currentMonth == 9 || currentMonth == 11) { //If we have > 30 days then tomorrow will be in next month and the day will be 1 if (tomorrowDay > 30) { tomorrowMonth = currentMonth + 1; tomorrowDay = 1; } } return daysPerMonth(); } private void leapYears() { //In Feb we have the leap year stuff if ((currentYear % 4 == 0) && (!(currentYear % 100 == 0) || (currentYear % 400) == 0)) { if (tomorrowDay > 29) { tomorrowMonth = 3; tomorrowDay = 1; } } else { if (tomorrowDay > 28) { tomorrowMonth = 3; tomorrowDay = 1; } } if (tomorrowMonth == 13) { tomorrowMonth = 1; tomorrowYear = currentYear + 1; } } private int theYears() { if (currentYear < 100) { if (currentYear > 40) { currentYear = currentYear + 1900; } else { currentYear = currentYear + 2000; } } return theYears(); } } more

Resolved Question: Java? Output data from another class?

Hi, Can anyone tell me how I can output data from another class? I have a class called Test where the user enters a number I want to output that number in a class called Answer How do I initalize the class Test in the class Answer? more

Resolved Question: IT Career - MC-TS Technology Specialist (TS) Exam 70-526: TS: Microsoft .NET Framework 3.5?

I am a recent graduate and have a first class honours in a general IT degree applied Information technology (Programming in Jsp, Actionscript and VBA, Relational databases (MS access) and Networking) I am now studying and half way through my MC-TS vb.net and also doing the following city and guilds level 2 courses:- Web design Vb.net Java C++ Software testing Do you think MC-TS have real value when wanting to start a career in programming when education is you only real life experience of vb.net? I was previously a developer, application support technician and software tester but using the less than popular database packages Informix and Ingres. Will having a MC-TS vb.net and a degree open doors to me? more

Resolved Question: Help using Java objects (newbie)?

Hey I need help writing a program to store employee payroll details. The employee payroll record is to be represented as the following: an integer giving their payroll number, String to store their name and their salary (an integer) e.g. 83 “Joe Brown” 1500 I need to write a class definition to represent such payroll details. I also need write a main method that declares and initialises a new employee payroll object using the example: 83 Joe Brown 1500 for employee Joe Brown with number 83 whose salary is £1500 per month. Thanks Sally more

Top Java Class Links