What is wrong with this program segment? I could not understand the error..
public class Hmw3
public static char[] myMethod(char[]p1,int p2, char p3)
{ //13 th row
if(p2<p1.length)
p1[p2]=p3;
System.out.println(p1);
public static void main(String[] args)
String sentence="It snows";
char[] tmp=sentence.toCharArray();
System.out.println(tmp);
myMethod(tmp,3,'k');
sentence=String.copyValueOf(tmp);
System.out.println(sentence);
i wrote this program segment and compiler gave this error:
C:\Program Files\Xinox Software\JCreator LE\MyProjects\hmw3\Hmw3.java:13: missing return statement
What is wrong???
Your method signature states that myMethod should return an array for chars.
But in ur implementation of myMethod, there is nothing returned.
Just add a return statement like "return p1"
Similar Messages
-
What's wrong with this MySQL connection? "Could not create connection to database server"
I'm able to connect to other MySQL databases but this one particular remote MySQL connection isn't working and I cannot figure it out. It probably has something to do with the remote server, not CF, but I thought I'd post it here if anyone had an idea. The MySQL account has full priviledges.
Here is the message when I try to validate the data source:
Connection verification failed for data source: test
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
The root cause was that: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.This happened on two servers. One one, the cause was that skip-networking was turned on. In the other situation, it appears that the database name was case sensitive, so TEST was not the same as test. Even though I edited the data source in the CF administrator, it still didn't work (very misleading). When a coworker entered a new data source with the same information (uppercase database name this time from the start), it worked.
Has anyone else seen this problem with the case sensitive database names? And with the data source in CF not updating the case correctly? Seems like a bug in CF. -
I have the serial number & the MEID. Now what do I with this information? I do not remembe the passcode to my lock screen
The serial and other ID numbers are of no use in a situation where you forgot the passcode.
Here's what you need to do:
http://support.apple.com/kb/HT1212 -
What's wrong with this program?
/* Daphne invests $100 at 10% simple interest. Deirdre invests $100 at 5% interest compounded annually. Write a program that finds how many years it takes for the value of Deirdre's investment to exceed the value of Daphne's investment. Aso show the two values at that time.*/
#include <stdio.h>
#define START 100.00
int main(void)
int counter = 1;
float daphne = START;
float deirdre = START;
printf("Daphne invests $100 at 10 percent simple interest. Deirdre invests $100 at 5 percent interest compounded annually.
When will Deirdre's account value exceed Daphne's?
Let\'s find out.
while (daphne > deirdre)
daphne += 10.00;
deirdre *= 1.05;
printf("%f %f
", daphne, deirdre);
printf("At year %d, Daphne has %.2f dollars. Deirdre has %.2f dollars.
", counter, daphne, deirdre);
counter++;
printf("By the end of year %d, Deirdre's account has surpassed Daphne's in value.
", counter);
return 0;
This is my output:
*Daphne invests $100 at 10 percent simple interest. Deirdre invests $100 at 5 percent interest compounded annually.*
*When will Deirdre's account value exceed Daphne's?*
*Let's find out.*
*By the end of year 1, Deirdre's account has surpassed Daphne's in value.*
What's wrong with it?
Message was edited by: musicwind95
Message was edited by: musicwind95John hadn't responded at the time I started typing this, but I'll keep it posted anyways in order to expand on John's answer a little bit. The answer to your last question is that the loop's condition has to return true for it to run the first time around. To examine this further, let's take a look at the way you had the while loop before:
while (daphne > deirdre)
Now, a while loop will run the code between its braces as long as the condition inside the parenthesis (daphne > deirdre, in this case) is true. So, if the condition is false the first time the code reaches the while statement, then the loop will never run at all (it won't even run through it once -- it will skip over it). And since, before the while loop, both variables (daphne and dierdre) are set equal to the same value (START (100.00), in this case), both variables are equal at the point when the code first reaches the while statement. Since they are equal, daphne is NOT greater than dierdre, and therefore the condition returns false. Since the condition is false the first time the code reaches it, the code inside the loop's braces is skipped over and never run. As John recommended in the previous post, changing it to this:
while (daphne >= deirdre)
fixes the problem because now the condition is true. The use of the "greater than or equal to" operator (>=) instead of the "great than" operator (>) means that the condition can now be returned true even if daphne is equal to deirdre, not just if it's greater than deirdre. And since daphne and deirdre are equal (they are both 100.00) when the code first reaches the while loop, the condition is now returned true and the code inside the loop's braces will be run. Once the program reaches the end of the code inside the loop's braces, it will check to see if the condition is still true and, if it is, it will run the loop's code again (and again and again and again, checking to see if the condition is still true each time), and if it's not true, it will skip over the loop's bottom brace and continue on with the rest of the program.
Hope this helped clear this up for you. Please ask if you have any more questions. -
What is wrong with this program?
When I run a get these messages:
^
MULTIPLYIMP.java:25: 'class' or 'interface' expected
^
MULTIPLYIMP.java:7: cannot resolve symbol
symbol : class UnicastRemoteObject
location: class MULTIPLYIMP
UnicastRemoteObject implements multiply {
^
MULTIPLYIMP.java:6: MULTIPLYIMP should be declared abstract; it does not define
greet() in MULTIPLYIMP
public class MULTIPLYIMP extends
^
MULTIPLYIMP.java:11: cannot resolve symbol
symbol : method supa ()
location: class MULTIPLYIMP
supa (); //Export
^
MULTIPLYIMP.java:15: missing method body, or declare abstract
public int mult (int a,int b) throws RemoteException
^
9 errors
//MULTIPLYIMPL.JAVA
import java.rmi.*;
import .rmi.server.*;
public class MULTIPLYIMP extends
unicastRemoteObject implements multiply {
public MULTIPLYIMPL () throwsRemoteException {
supa (); //Export
public int mult (int a,int b) throws RemoteException
return (a * b)
public String greet () throws RemoteException
return("CCM 3061");When I run a get these messages:
^
MULTIPLYIMP.java:25: 'class' or 'interface' expected
^
MULTIPLYIMP.java:7: cannot resolve symbol
symbol : class UnicastRemoteObject
location: class MULTIPLYIMP
UnicastRemoteObject implements multiply {
^
You haven't imported the right package.
You need to import
java.rmi.server.UnicastRemoteObject
or
java.rmi.server.*
MULTIPLYIMP.java:6: MULTIPLYIMP should be declared
abstract; it does not define
greet() in MULTIPLYIMP
public class MULTIPLYIMP extends
^
It says that you don't define greet() because it doesn't have curly braces after the method name.
I'm reasonably sure
public String greet () throws RemoteException
return("CCM 3061");is not acceptable, usepublic String greet () throws RemoteException
return("CCM 3061");
MULTIPLYIMP.java:11: cannot resolve symbol
symbol : method supa ()
location: class MULTIPLYIMP
supa (); //Export
^
MY GOD MAN, SUPER(), SUPER!!!!!!
MULTIPLYIMP.java:15: missing method body, or declare
abstract
public int mult (int a,int b) throws RemoteException
^
9 errors
Same with mult(), need to have curly braces around the method body
//MULTIPLYIMPL.JAVA
import java.rmi.*;
WHAT IS THIS LINE?
import java.rmi.server.*
import .rmi.server.*;
public class MULTIPLYIMP extends
unicastRemoteObject implements multiply {
public MULTIPLYIMPL () throwsRemoteException {
supa (); //Export
public int mult (int a,int b) throws RemoteException
return (a * b)
public String greet () throws RemoteException
return("CCM 3061");
}Messy messy code mate,
Good luck,
Radish21 -
What is wrong with this program it keeps telling me the file doesn't exist?
this program is supposed to write the file so why does it need the file to already exist?
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class NewClass implements ActionListener{
static List list = new List();
static TextField input = new TextField(20);
static Button submit = new Button("Submit");
static Frame f = new Frame("RealmList editor");
static File file = new File("/Applications/World of Warcraft/realmlist.wtf");
static Label status = new Label("");
static Button selected = new Button("Change to Selected");
static File config = new File("/Applications/RealmLister/config.txt");
static File dir = new File("/Applications/RealmLister/");
public static void main(String[] args) {
f.setLayout(new BorderLayout());
f.add(list, BorderLayout.CENTER);
Panel p = new Panel();
p.add(input);
p.add(submit);
p.add(selected);
f.add(p, BorderLayout.NORTH);
f.add(status, BorderLayout.SOUTH);
new NewClass();
f.setSize(500,500);
f.setVisible(true);
try {
loadConfig();
} catch(Exception e) {}
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
try {
writeConfig();
System.exit(0);
} catch(Exception e) {
status.setText("Error: config couldn't be written!("+e+")");
public NewClass() {
submit.addActionListener(this);
input.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_ENTER) {
try {
editRealmlist(input.getText(), true);
input.setText("");
catch(Exception ex) {
status.setText("Error: "+e);
selected.addActionListener(this);
public void actionPerformed(ActionEvent e) {
if(e.getSource() == submit) {
try {
editRealmlist(input.getText(), true);
input.setText("");
} catch(Exception ex) {
status.setText("Error: "+e);
wait(3000);
status.setText("");
if(e.getSource() == selected) {
try {
editRealmlist(list.getSelectedItem(),false);
} catch(Exception ex) {
status.setText("Error: "+e);
wait(3000);
status.setText("");
public static void loadConfig() throws Exception{
if(config.exists()) {
Scanner scan = new Scanner(config);
ArrayList<String> al = new ArrayList<String>();
while(scan.hasNext()) {
al.add(scan.nextLine());
for(int i = 0; i < al.size(); i++) {
list.add(al.get(i));
public static void writeConfig() throws Exception{
FileWriter fw = new FileWriter(config);
dir.mkdir();
config.mkdirs();
String temp = "";
for(int i = 0; i < list.getItemCount(); i++) {
temp += list.getItem(i)+"\n";
fw.write(temp);
fw.flush();
System.gc();
public static void editRealmlist(String realm, boolean addtoList) throws Exception{
FileWriter fw = new FileWriter(file);
fw.write("set realmlist "+realm+"\nset patchlist us.version.worldofwarcraft.com");
fw.flush();
status.setText("Editing RealmList.wtf Please Wait...");
Thread.sleep(3000);
status.setText("");
System.gc();
if(addtoList)
list.add(realm);
public void wait(int time) {
try {
Thread.sleep(time);
catch(Exception e) {}
}Erm, you should call mkdirs() on a File object that represents a directory.
-
error
19e529fd-3785-410e-ad4e-f4c8542ade52 2014-03-17T21:40:59.079Z err { message: '@D
efault is not a parameter for procedure sp_Address_UPDATE.',? type: 'alert',?
stack: 'Error: @Default is not a parameter for procedure sp_Address_UPDATE.\n
at TDSStream.onRequestComplete (c:\Projects\caa-api\lib\data\tedious\TDSS
tream.js:67:11)\n at Request.callback (c:\Projects\caa-api\node_modules\t
edious\lib\request.js:24:27)\n at PooledConnection.Connection.STATE.SENT_CL
IENT_REQUEST.events.message (c:\Projects\caa-api\node_modules\tedious\lib\
connection.js:198:29)\n at PooledConnection.Connection.dispatchEvent (c:\Pro
jects\caa-api\node_modules\tedious\lib\connection.js:465:59)\n at Messag
eIO. (c:\Projects\caa-api\node_modules\tedious\lib\connection.j
s:419:20)\n at MessageIO.EventEmitter.emit (events.js:92:17)\n at MessageI
O.eventData (c:\Projects\caa-api\node_modules\tedious\lib\message-io.js:59
:21)\n at CleartextStream. (c:\Projects\caa-api\node_modules\t
edious\lib\message-io.js:3:59)\n at CleartextStream.EventEmitter.emit (even
ts.js:95:17)\n at CleartextStream. (_stream_readable.js:746:14)' }
existing Proc
sp_helptext sp_Address_UPDATE
CREATE PROCEDURE [dbo].[sp_Address_UPDATE]
@AddressID INT OUTPUT,
@Line1 NVARCHAR(400) = NULL,
@Line2 NVARCHAR(400) = NULL,
@Line3 NVARCHAR(400) = NULL,
@UnitNumber NVARCHAR(30) = NULL,
@City NVARCHAR(400) = NULL,
@StateProvinceID INT = NULL,
@PostalCode NVARCHAR(50) = NULL,
@CountryID INT = NULL,
@Latitude NUMERIC(30, 8) = NULL,
@Longitude NUMERIC(30, 8) = NULL,
@Elevation NUMERIC(30, 8) = NULL,
@Active SMALLINT = NULL,
@ModifiedBy NVARCHAR(50) = NULL,
@Error NVARCHAR(400) = NULL OUTPUT,
@Locality NVARCHAR(400)=NULL,
@AdministrativeArea NVARCHAR(400)=NULL,
@AdministrativeSubArea NVARCHAR(400)=NULL,
@Country NVARCHAR(400)=NULL
AS
IF @Country IS NOT NULL
SELECT @Countryid = CountryId
FROM countries
WHERE ( Country = @Country )
OR ( CountryAbrv2 = @Country )
OR ( CountryAbrv3 = @Country )
IF @AdministrativeArea IS NOT NULL
SELECT @StateProvinceID = StateProvinceID
FROM StateProvince
WHERE ( abbreviation = @AdministrativeArea )
OR ( name = @AdministrativeArea )
-- BEGIN TRAN
UPDATE a
SET Line1 = ISNULL(@Line1, a.Line1),
Line2 = ISNULL(@Line2, a.Line2),
Line3 = ISNULL(@Line3, a.Line3),
UnitNumber = ISNULL(@UnitNumber, a.UnitNumber),
City = ISNULL(@City, a.City),
StateProvinceID = CASE
WHEN AdministrativeArea IS NOT NULL
AND @StateProvinceID IS NULL THEN NULL
ELSE ISNULL(@StateProvinceID, a.StateProvinceID)
END,
PostalCode = ISNULL(@PostalCode, a.PostalCode),
CountryID = CASE
WHEN Country IS NOT NULL
AND @CountryID IS NULL THEN NULL
ELSE ISNULL(@CountryID, a.CountryID)
END,
Latitude = ISNULL(@Latitude, a.Latitude),
Longitude = ISNULL(@Longitude, a.Longitude),
Elevation = ISNULL(@Elevation, a.Elevation),
Active = ISNULL(@Active, a.Active),
ModifiedDate = GETDATE(),
ModifiedBy = ISNULL(@ModifiedBy, ModifiedBy),
locality = ISNULL(@locality, locality),
AdministrativeArea = ISNULL(@AdministrativeArea, AdministrativeArea),
AdministrativeSubArea = ISNULL(@AdministrativeSubArea, AdministrativeSubArea),
Country = ISNULL(@Country, Country),
geogcode = CASE
WHEN @latitude IS NOT NULL
AND @longitude IS NOT NULL THEN geography::STPointFromText('POINT(' + CAST(@Longitude AS VARCHAR(20))
+ ' ' + CAST(@Latitude AS VARCHAR(20)) + ')', 4326)
ELSE NULL
END,
geocode = CASE
WHEN @latitude IS NOT NULL
AND @longitude IS NOT NULL THEN geometry::STPointFromText('POINT(' + CAST(@Longitude AS VARCHAR(20))
+ ' ' + CAST(@Latitude AS VARCHAR(20)) + ')', 4326)
ELSE NULL
END
FROM [Address] a
WHERE a.AddressID = @AddressID
IF EXISTS(SELECT *
FROM address
WHERE Addressid = @addressid
AND ( locality IS NOT NULL
OR AdministrativeArea IS NOT NULL
OR country IS NOT NULL ))
SELECT AddressID,
Line1,
Line2,
Line3,
UnitNumber,
isnull(Locality, City) AS 'Locality',
a.StateProvinceID,
isnull(administrativeArea, S.Name) AS 'AdministrativeArea',
AdministrativeSubArea,
a.PostalCode,
a.CountryID,
isnull(c.Country, a.Country) AS Country,
a.Latitude,
a.Longitude,
a.Elevation,
a.ModifiedBy,
a.ModifiedDate
FROM [Address] a
LEFT JOIN stateprovince s
ON s.stateprovinceid = a.stateprovinceid
LEFT JOIN Countries c
ON c.Countryid = a.Countryid
WHERE AddressID = @AddressID
ELSE
SELECT AddressID,
Line1,
Line2,
Line3,
UnitNumber,
City,
StateProvinceID,
PostalCode,
CountryID,
Latitude,
Longitude,
Elevation,
ModifiedBy,
ModifiedDate
FROM [Address]
WHERE AddressID = @AddressID
RETURN @AddressIDNothing in the procedure is right. The “sp_” prefix has special meaning in T-SQL, so the name is wrong. THEN it gets even worse.
No postal service in Earth uses 400 character address lineS. Can you give me an exampelf of a city_ with 400 characters?
Longitude and latitude are done with FLOAT because of the math used. ISO country codes are CHAR(3). Addresses do not have an id; we have “<something>_address” in RDBMS. Do you want some industry standard like the SAN?
The (ModIFiedBy, ModIFiedDate) pair is audit data, so it is illegal to have it in the table under audit.
Your code is BASIC or COBOL written in T-SQL with 1960's with IF-THEN control flow and not in declarative SQL! Why did you fail to use COALESCE?
Look at how to write a MERGE statement and get rid of this procedure. And look at an address scrubbing tool for the data. In the future, post DDL and follow minimal Netiquette.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
What's wrong with this program that about socket
package example;
import java.net.*;
import java.io.*;
public class Server implements Runnable{
Thread t;
ServerSocket sSocket;
int sPort=6633;
public Server(){
try{
sSocket=new ServerSocket(sPort);
System.out.println("server start....");
}catch(IOException e){
e.printStackTrace();
t=new Thread(this);
t.start();
public void run(){
try{
while(true){
Socket cSocket=sSocket.accept();
ClientThread cThread=new ClientThread(cSocket);
cThread.start();
}catch(IOException e){
e.printStackTrace();
public static void main(String[] args){
new Server();
package example;
import java.net.*;
import java.io.*;
public class ClientThread extends Thread{
Socket cSocket;
PrintStream writer;
BufferedReader reader;
public ClientThread(Socket s){
cSocket=s;
try{
writer=new PrintStream(cSocket.getOutputStream());
reader=new BufferedReader(new InputStreamReader(cSocket.getInputStream()));
}catch(IOException e){
e.printStackTrace();
public void run(){
try{
while(true){
String message=reader.readLine();
System.out.println("Server get:"+message);
}catch(IOException e){
e.printStackTrace();
package example;
import java.net.*;
import java.io.*;
public class Client{
public static void main(String[] args){
String ipaddr="localhost";
PrintStream writer;
try{
Socket cSocket=new Socket(ipaddr,6633);
System.out.println(cSocket);
writer=new PrintStream(cSocket.getOutputStream());
System.out.println("client send:hello");
writer.print("hello");
catch(Exception e){
e.printStackTrace();
}first,I run Server,and then I run Client,
output at Server:
server start....
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.net.SocketInputStream.read(SocketInputStream.java:90)
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:285)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at example.ClientThread.run(ClientThread.java:20)
what' wrong??????In your Client class, after doing writer.print("hello"); you should flush
the output stream. As it is now, you attempt to write something (without actually
sending something to your server) and main simply terminates. The server,
still waiting for some input (you didn't flush on the client side), is confronted with
a closed client socket (main on the client side terminated and implicitly closed
the client socket), hence the 'connection reset' exception on the server side.
kind regards,
Jos -
What's wrong with this program, nothing displays.
Compile ok, but nothing displays.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Card{
JFrame f;
JLabel nameTF;
JComboBox jobChoice;
JButton B1, B2, B3, B4;
public static void main(String[] av) {
new Card( );
public Card( ) {
f=new JFrame();
f.setSize(500,500);
Container cp = f.getContentPane( );
cp.setLayout(new GridLayout(0, 1));
f.addWindowListener(new WindowAdapter( ) {
public void windowClosing(WindowEvent e) {
f.setVisible(false);
f.dispose( );
System.exit(0);
JMenuBar mb = new JMenuBar( );
f.setJMenuBar(mb);
JMenu aMenu;
aMenu = new JMenu("filemenu");
mb.add(aMenu);
JMenuItem mi = new JMenuItem("exit");
aMenu.add(mi);
mi.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e) {
System.exit(0);
aMenu = new JMenu("editmenu");
mb.add(aMenu);
aMenu = new JMenu("viewmenu");
mb.add(aMenu);
aMenu = new JMenu("optionsmenu");
mb.add(aMenu);
aMenu =new JMenu("helpmenu");
mb.add(aMenu);
JPanel p1 = new JPanel( );
p1.setLayout(new GridLayout(0, 1, 50, 10));
nameTF = new JLabel("My Name", JLabel.CENTER);
nameTF.setFont(new Font("helvetica", Font.BOLD, 18));
nameTF.setText("MYNAME");
p1.add(nameTF);
jobChoice = new JComboBox( );
jobChoice.setFont(new Font("helvetica", Font.BOLD, 14));
String next;
int i=1;
do {
next = "job_title" + i;
if (next != null)
jobChoice.addItem(next);
} while (next != null);
p1.add(jobChoice);
cp.add(p1);
JPanel p2 = new JPanel( );
p2.setLayout(new GridLayout(2, 2, 10, 10));
B1 = new JButton( );
B1.setText("button1.label");
p2.add(B1);
B2 = new JButton( );
B2.setText("button2.label");
p2.add(B2);
B3 = new JButton( );
B3.setText("button3.label");
p2.add(B3);
B4 = new JButton( );
B4.setText("button4.label");
p2.add(B4);
cp.add(p2);
f.pack( );
f.show();
}hi there
try this code i changed a little bil and one more thing yr LOOP is not working Properly check that out
rest is fine
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Card extends JFrame
JLabel nameTF;
JComboBox jobChoice;
JButton B1, B2, B3, B4;
public static void main(String[] av)
Card C = new Card( );
C.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public Card( )
setSize(500,500);
Container cp = getContentPane( );
cp.setLayout(new GridLayout(0, 1));
addWindowListener(new WindowAdapter( )
public void windowClosing(WindowEvent e)
dispose( );
System.exit(0);
JMenuBar mb = new JMenuBar( );
setJMenuBar(mb);
JMenu aMenu;
aMenu = new JMenu("filemenu");
mb.add(aMenu);
JMenuItem mi = new JMenuItem("exit");
aMenu.add(mi);
mi.addActionListener(new ActionListener( )
public void actionPerformed(ActionEvent e)
dispose( );
System.exit(0);
aMenu = new JMenu("editmenu");
mb.add(aMenu);
aMenu = new JMenu("viewmenu");
mb.add(aMenu);
aMenu = new JMenu("optionsmenu");
mb.add(aMenu);
aMenu =new JMenu("helpmenu");
mb.add(aMenu);
JPanel p1 = new JPanel( );
p1.setLayout(new GridLayout(0, 1, 50, 10));
nameTF = new JLabel("My Name", JLabel.CENTER);
nameTF.setFont(new Font("helvetica", Font.BOLD, 18));
nameTF.setText("MYNAME");
p1.add(nameTF);
jobChoice = new JComboBox( );
jobChoice.setFont(new Font("helvetica", Font.BOLD, 14));
String next;
// int i=1;
// do
// next = "job_title" + i;
// if (next != null)
// jobChoice.addItem(next);
// } while (next != null);
p1.add(jobChoice);
cp.add(p1);
JPanel p2 = new JPanel( );
p2.setLayout(new GridLayout(2, 2, 10, 10));
B1 = new JButton( );
B1.setText("button1.label");
p2.add(B1);
B2 = new JButton( );
B2.setText("button2.label");
p2.add(B2);
B3 = new JButton( );
B3.setText("button3.label");
p2.add(B3);
B4 = new JButton( );
B4.setText("button4.label");
p2.add(B4);
cp.add(p2);
pack( );
setVisible(true);
}Regards
Satinderjit -
Does ANYONE know whats wrong with this program?!?!
Hey(again),
Does anyone know whats wrong with this program?:
public class FloatingNumbersTest
public static void main(String args[])
float float1 =50.0f;
float closeFloat=0.001f
float farfloat=100.0f
if (float1<=closeFloat)
System.out.print("Float1 pretty close to zero");
if (float1>=closeFloat)
System.out.print("Float1 is near 0");
if (float1>=farfloat)
System.out.print("Float1 is not even close to zero!"0
}There has seemed to be 5 errors!public class FloatingNumbersTest
public static void main(String args[])
float float1 =50.0f;
float closeFloat=0.001f
float farfloat=100.0f
if (float1<=closeFloat)
HERE System.out.print("Float1 pretty close to zero");
if (float1>=closeFloat)
System.out.print("Float1 is near 0");
if (float1>=farfloat)
System.out.print("Float1 is not even close to zero!"0
}you're missing the opening { for the first if. -
I can't figure out what's wrong with this code
First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
One two buckle your shoe
Three four shut the door
Five six pick up sticks
Seven eight lay them straight
Nine ten this is the end.
The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
public class PoemSeventeen
public static void main(String[] args)
EasyReader console = new EasyReader();
System.out.println("Enter a number for the poem (0 to quit): ");
int n = console.readInt();
if (n = 1) || (n = 2)
System.out.println("One, two, buckle your shoe");
else if (n = 3) || (n = 4)
System.out.println("Three, four, shut the door");
else if (n = 5) || (n = 6)
System.out.println("Five, six, pick up sticks");
else if (n = 7) || (n = 8)
System.out.println("Seven, eight, lay them straight");
else if (n = 9) || (n = 10)
System.out.println("Nine, ten, this is the end");
else if (n = 0)
System.out.println("You may exit now");
else
System.out.println("Put in a number between 0 and 10");
I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
The EasyReader class code:
// package com.skylit.io;
import java.io.*;
* @author Gary Litvin
* @version 1.2, 5/30/02
* Written as part of
* <i>Java Methods: An Introduction to Object-Oriented Programming</i>
* (Skylight Publishing 2001, ISBN 0-9654853-7-4)
* and
* <i>Java Methods AB: Data Structures</i>
* (Skylight Publishing 2003, ISBN 0-9654853-1-5)
* EasyReader provides simple methods for reading the console and
* for opening and reading text files. All exceptions are handled
* inside the class and are hidden from the user.
* <xmp>
* Example:
* =======
* EasyReader console = new EasyReader();
* System.out.print("Enter input file name: ");
* String fileName = console.readLine();
* EasyReader inFile = new EasyReader(fileName);
* if (inFile.bad())
* System.err.println("Can't open " + fileName);
* System.exit(1);
* String firstLine = inFile.readLine();
* if (!inFile.eof()) // or: if (firstLine != null)
* System.out.println("The first line is : " + firstLine);
* System.out.print("Enter the maximum number of integers to read: ");
* int maxCount = console.readInt();
* int k, count = 0;
* while (count < maxCount && !inFile.eof())
* k = inFile.readInt();
* if (!inFile.eof())
* // process or store this number
* count++;
* inFile.close(); // optional
* System.out.println(count + " numbers read");
* </xmp>
public class EasyReader
protected String myFileName;
protected BufferedReader myInFile;
protected int myErrorFlags = 0;
protected static final int OPENERROR = 0x0001;
protected static final int CLOSEERROR = 0x0002;
protected static final int READERROR = 0x0004;
protected static final int EOF = 0x0100;
* Constructor. Prepares console (System.in) for reading
public EasyReader()
myFileName = null;
myErrorFlags = 0;
myInFile = new BufferedReader(
new InputStreamReader(System.in), 128);
* Constructor. opens a file for reading
* @param fileName the name or pathname of the file
public EasyReader(String fileName)
myFileName = fileName;
myErrorFlags = 0;
try
myInFile = new BufferedReader(new FileReader(fileName), 1024);
catch (FileNotFoundException e)
myErrorFlags |= OPENERROR;
myFileName = null;
* Closes the file
public void close()
if (myFileName == null)
return;
try
myInFile.close();
catch (IOException e)
System.err.println("Error closing " + myFileName + "\n");
myErrorFlags |= CLOSEERROR;
* Checks the status of the file
* @return true if en error occurred opening or reading the file,
* false otherwise
public boolean bad()
return myErrorFlags != 0;
* Checks the EOF status of the file
* @return true if EOF was encountered in the previous read
* operation, false otherwise
public boolean eof()
return (myErrorFlags & EOF) != 0;
private boolean ready() throws IOException
return myFileName == null || myInFile.ready();
* Reads the next character from a file (any character including
* a space or a newline character).
* @return character read or <code>null</code> character
* (Unicode 0) if trying to read beyond the EOF
public char readChar()
char ch = '\u0000';
try
if (ready())
ch = (char)myInFile.read();
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
if (ch == '\u0000')
myErrorFlags |= EOF;
return ch;
* Reads from the current position in the file up to and including
* the next newline character. The newline character is thrown away
* @return the read string (excluding the newline character) or
* null if trying to read beyond the EOF
public String readLine()
String s = null;
try
s = myInFile.readLine();
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
if (s == null)
myErrorFlags |= EOF;
return s;
* Skips whitespace and reads the next word (a string of consecutive
* non-whitespace characters (up to but excluding the next space,
* newline, etc.)
* @return the read string or null if trying to read beyond the EOF
public String readWord()
StringBuffer buffer = new StringBuffer(128);
char ch = ' ';
int count = 0;
String s = null;
try
while (ready() && Character.isWhitespace(ch))
ch = (char)myInFile.read();
while (ready() && !Character.isWhitespace(ch))
count++;
buffer.append(ch);
myInFile.mark(1);
ch = (char)myInFile.read();
if (count > 0)
myInFile.reset();
s = buffer.toString();
else
myErrorFlags |= EOF;
catch (IOException e)
if (myFileName != null)
System.err.println("Error reading " + myFileName + "\n");
myErrorFlags |= READERROR;
return s;
* Reads the next integer (without validating its format)
* @return the integer read or 0 if trying to read beyond the EOF
public int readInt()
String s = readWord();
if (s != null)
return Integer.parseInt(s);
else
return 0;
* Reads the next double (without validating its format)
* @return the number read or 0 if trying to read beyond the EOF
public double readDouble()
String s = readWord();
if (s != null)
return Double.parseDouble(s);
// in Java 1, use: return Double.valueOf(s).doubleValue();
else
return 0.0;
Can anybody please tell me what's wrong with this code? ThanksString[] message = {
"One, two, buckle your shoe",
"One, two, buckle your shoe",
"Three, four, shut the door",
"Three, four, shut the door",
"Five, six, pick up sticks",
"Five, six, pick up sticks",
"Seven, eight, lay them straight",
"Seven, eight, lay them straight",
"Nine, ten, this is the end",
"Nine, ten, this is the end"
if(n>0)
System.out.println(message[n]);
else
System.exit(0); -
I HATE my new MACBOOK PRO, it will not let me open any PDF files and I downloaded the ADOBE READER three freaking times and it keeps saying that all the files are corrupt or damaged. I would rather have my 2008 Dell at this point. what is wrong with this thing
Perhaps the PDF files are corrupted.
Hit the command key and spacebar, a blue Spotlight in the upper right hand corner appears, now type Preview and press return on the Preview program.
Now you can try opening the PDF's from the file menu and see what's going on.
If they are corrupted, perhaps they are trojans from your Windows PC or gotten from a bad location online.
Download the free ClamXav and run a scan on the possibly infected folder. -
What is wrong with this code? on(release) gotoAndPlay("2")'{'
Please could someone tell me what is wrong with this code - on(release)
gotoAndPlay("2")'{'
this is the error that comes up and i have tried changing it but it is not working
**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: '{' expected
gotoAndPlay("2")'{'
Total ActionScript Errors: 1 Reported Errors: 1
ThanksIf you have a frame labelled "2" then it should be:
on (release) {
this._parent.gotoAndPlay("2");
or other wise just the following to go to frame 2:
on (release) {
this._parent.gotoAndPlay(2);
You just had a missing curly bracket... -
I just got my new iPad Mini2, and when I choose "sign in with your apple ID", it says that "there was a problem connecting to the server". What's wrong with this, and how can I deal with this problem?
1. Turn router off for 30 seconds and on again
2. Settings>General>Reset>Reset Network Settings -
What's wrong with this function
What's wrong with this Function(PL/SQL) in this formaula column definition in Reports 6i
function currdateFormula return Date is
curr_date date;
begin
select to_char(sysdate, 'DD-MM-YYYY') into curr_date from dual;
return(curr_date);
end;
I get the following error in compiling
REP-1401. 'currdateformula'.Fatal PL/SQL error occured. ORA-01843 not a valid month.
The SQL select to_char(sysdate, 'DD-MM-YYYY') from dual; worked well in SQL Plus prompt.
I got a clean compile when i use just sysdate in the function (see below).
function currdateFormula return Date is
curr_date date;
begin
select sysdate into curr_date from dual;
return(curr_date);
end;
Appreciate your help
Raja Lakshmihello,
what you are trying to do :
fetch the current date and return it as the result of the formula-column.
what you are actually doing :
fetch the current date, convert it to text, assign this text to a date-variable which causes an implicit type-conversion.
in your case you create a date-string with the format dd-mm-yyyy. the implicit conversion then tries to convert this string back to date using the NLS settings of your session. depending on your NLS_LANG and NLS_DATE_FORMAT this might work, if your session-date-format is dd-mm-yyyy which obviously it is NOT as you get the error.
what you should do :
select sysdate into curr_date from dual;
this fetches the sysdate and stores it in your date-variable. there is no type conversion needed what so ever.
regards,
the oracle reports team
Maybe you are looking for
-
IPod touch got wet, can not restore with iTunes
I have a first generation 16 GB iPod touch that wicked up water over night from a glass surface. I didn't notice the water until morning when I picked up the iPod. I tried to turn it on but it was dead. I dried it out using a desk lamp until moisture
-
How to install Pages on my Mac OS X 10.6.8 ?- when I try to install Pages I get message "the application requires Mac OS 10.9 or later! Do I have to convert or update my current iMac?
-
Considerations for 802.1x Port Based and Wi-Fi Certificate Authentication
Lately, we have been going back and for with the thought of doing certificate authentication for Wi-Fi and Port. We have Server 2012 PKI and CA and it seems fairly straight forward to pump out a certificate to a user and have them authenticate with t
-
Mac Pro (late 2013) adapters
What are the specifications for Mac Pro (late 2013) thunderbolt to Cinema and thunderbolt to FireWire adapters?
-
How to disable the header validation ?
I have a large number of pdf files on my network with the following error. Error: the document is damaged and cannot be repaired. Adobe Reader could not open because it is either not a supported file type or because the file has been damaged (for exa