Cannot be applied to (java.io.PrintWriter) error
Hi guys I get the following errors when trying to compile my program and I was wondering how to solve it
printPay() in PaySlip cannot be applied to (java.io.PrintWriter)
slip.printPay(slipWrite)
import java.io.*;
public class PayApp
public static void main(String[] args)
boolean end_of_file = false;
EmpInFile f1 = new EmpInFile();
EmpOutFile f2 = new EmpOutFile();
Employee emp = null;
PaySlip slip = null;
Report sum = null;
PrintWriter slipWrite = null;
PrintWriter sumWrite = null;
if (args.length != 4) // correct number ?
errExit("Names of Input employee file , output employee file, payslip file \n, and report file required");
emp = new Employee();
sum = new Report();
slip = new PaySlip(emp,sum);
try
f1.openFile(args[0]);
f2.openFile(args[1]);
slipWrite = new PrintWriter(new FileWriter(args[2]));
sumWrite = new PrintWriter(new FileWriter(args[3]));
catch(IOException e)
System.err.println("error opening files" + e.toString());
System.exit(1);
while (!end_of_file )
end_of_file = f1.readRecord(emp);
if(!end_of_file)
slip.printPay(slipWrite);
f2.addRecord(emp);
}// end if ! end
}// end while
System.out.println("All employees processed ");
sum.printTotals(sumWrite);
sumWrite.flush();
sumWrite.close();
slipWrite.flush();
slipWrite.close();
f1.closeFile();
f2.closeFile();
static void errExit(String message)
System.err.println(message);
System.exit(1);
public class PaySlip
// declare variables
private double gross;
private double tax;
private double taxcredits;
private Employee emp;
private Report rep;
public PaySlip (Employee e, Report r)
emp = e;
rep = r;
double gross = 0;
double tax = 0;
double taxcredits = 0;
public void setGross(double gr)
gross = gr;
public void setTax(double tx)
tax = tx;
public void settaxCreds(double taxcreds)
taxcredits = taxcreds;
public void printPay()
emp.calcPay(this);
double netpay;
netpay = gross - tax;
System.out.println("____________________________________________________");
System.out.println(" Payslip Information ");
System.out.println("Employee Name: \t\t" +emp.getFirst() +" "+ emp.getLast());
System.out.println("Employee Id: \t\t" +emp.getId());
System.out.println("Net Pay: \t" +netpay);
System.out.println("Year To Date Gross: \t" +emp.getYtdGross());
System.out.println("Year To Date Tax: \t" +emp.getYtdTax());
System.out.println("____________________________________________________");
System.out.println(" Department Totals ");
char dcode = emp.getDeptCode();
rep.addToTotals(gross,tax,dcode);
}Any help would be greatly appreciated.
Post the actual error which would in include a line number when noting errors.
slip.printPay(slipWrite); The method printPay() does not take parameters. So you can't put 'slipWrite" there.
Similar Messages
-
Ahhh!!!
Ahem, when I try to compile the file below, "PhoneDirectory.java", I get the following compilation error message:
PhoneDirectory.java:12: create(java.io.InputStream) in Scanner cannot be applied to (java.io.File)
Scanner fin = Scanner.create(file);After quite a bit of tweaking... I'm right back where I started. I'm a seasoned programmer, as far as concepts are concerned, but rather new to JAVA.
The error seems to be occuring where a new instance of "Scanner" is supposed to be created. It uses file I/O, and I had only used the Scanner class for the keyboard input in the past.
Looking at the Scanner class, everything seems to be right to me. I'm probably missing some simple fundamental concept, and I've been pulling my hair out trying to get it... Please help me shed some light on this situation!
=========
PhoneDirectory.java
=========
import java.io.*;
// Read a file of names and phone numbers
// into an array. Sort them into ascending
// order using bubble sort.
// Print names and numbers before and after sort.
public class PhoneDirectory {
public static void main (String[] args) {
PhoneEntry[] directory = new PhoneEntry[200];
File file = new File("c:\\jessica\\phonenum.txt");
Scanner fin = Scanner.create(file);
int numberEntries = 0;
// read array from file
while (fin.hasNextInt())
directory[numberEntries++] = new PhoneEntry(fin);
// print array as read
for (int i=0; i<numberEntries; i++)
System.out.println(directory);
// sort by ordering defined in PhoneEntry,
// in this case lastName firstName
bubbleSort(directory, numberEntries);
// print sorted array
System.out.println(
"============================================");
for (int i=0; i<numberEntries; i++)
System.out.println(directory[i]);
static void bubbleSort(PhoneEntry[] a, int size) {
// bubbleSortr: simple to write, but very inefficient.
PhoneEntry x;
for (int i=1; i<size; i++)
for (int j=0; j<size-i; j++)
if (a[j].compareToIgnoreCase(a[j+1]) > 0) {
// swap
x = a[j]; a[j] = a[j+1]; a[j+1] = x;
=========
PhoneEntry.java
=========
class PhoneEntry {
// number, name entry for a line in a Phone Directory
protected int area;
protected int prefix;
protected int number;
protected String firstName;
protected String lastName;
public String toString() {
// format name and phone number to printable string
String x = lastName + ", " + firstName;
x = x +
" . . . . . . . . . . . . . . .".substring(x.length())
+ "(" + area + ") " + prefix + "-" + number;
return x;
public int compareToIgnoreCase(PhoneEntry v) {
// alphabetically compare names in this to names in v
// return negative for this < v, 0 for ==,
// positive for this > v
int m = lastName.compareToIgnoreCase(v.lastName);
if (m == 0) m = firstName.compareToIgnoreCase(v.firstName);
return m;
public PhoneEntry(Scanner fin) {
// input a PhoneDirectory entry. Must be space delimited
// area prefix suffix lastname firstname
// number
area = fin.nextInt();
prefix = fin.nextInt();
number = fin.nextInt();
// read rest of line
String name = fin.nextLine();
// split name into lastName firstName
int p = name.indexOf(' ');
if (p > 0) {
lastName = name.substring(0,p);
firstName = name.substring(p+1);
else {
lastName = name;
firstName = "";
}=========
Scanner.java
=========
This class does input from the keyboard. To use it you
create a Scanner using
Scanner stdin = Scanner.create(System.in);
then you can read doubles, ints, or strings as follows:
double d; int i; string s;
d = stdin.nextDouble();
i = stdin.nextInt();
s = stdin.nextLine();
An unexpected input character will cause an exception.
You cannot type a letter when it's expecting a double,
nor can you type a decimal point when it's expecting an int.
import java.io.*;
public class Scanner {
// Simplifies input by returning
// the next value read from the
// keyboard with each call.
private String s;
private int start=0, end = 0, next;
private BufferedReader stdin;
Scanner(InputStream stream) {
start = end = 0;
// set up for keyboard input
stdin = new BufferedReader(
new InputStreamReader(stream));
public static Scanner create(InputStream stream) {
return new Scanner(stream);
double nextDouble() {
if (start >= end)
try {
s = stdin.readLine().trim() + " ";
start = 0;
end = s.length();
catch (IOException e) {System.exit(1);}
next = s.indexOf(' ',start);
double d = Double.parseDouble(s.substring(start,next));
start = next+1;
return d;
public int nextInt() {
if (start >= end)
try {
s = stdin.readLine().trim() + " ";
start = 0;
end = s.length();
catch (IOException e) {System.exit(1);}
next = s.indexOf(' ',start);
int d = Integer.parseInt(s.substring(start,next));
start = next+1;
return d;
public String nextLine() {
if (start >= end)
try {
s = stdin.readLine().trim() + " ";
start = 0;
end = s.length();
catch (IOException e) {System.exit(1);}
String t = s.substring(start,s.length()-1);
start = end = 0;
return t;
}=========
phonenum.txt
=========
336 746 6915 Rorie Tim
336 746 6985 Johnson Gary
336 781 2668 Hoyt James
606 393 5355 Krass Mike
606 393 5525 Rust James
606 746 3635 Smithson Norman
606 746 3985 Kennedy Amy
606 746 4235 Behrends Leonard
606 746 4395 Rueter Clarence
606 746 4525 Rorie LonnieI don't see a Scanner.create() method in the Scanner class but I do see a constructor with the signature you want. Change
Scanner fin = Scanner.create(file);
to
Scanner fin = new Scanner(file); -
String cannot be applied to java.lang.String in NetBeans 6 !?!?
Guys,
I have a problem. I am calling some API from jar file. Here is the method prototype in API jar:
public Operator getAdminOperator(String name, String password, int admin);
when I call this method in NetBeans 6 like the following:
admin.getAdminOperator(userName, password, 1);
where userName and password are both string, I get the following error:
getAdminOperator(String, String, int) in common.admin.AdminRemote cannot be applied to (java.lang.String, java.lang.String, int)
WTF?!?! If i try the same code in NetBeans 5 it works, and it works in JavaStudioCreator, but NetBeans 6 does not takes it! And because of this error, I am not able to see the Design view in the JSF! The code compiles just fine and runs if I deploy it in the server though, but i need to see the Design view.
ANY ideas what is going on?Then this "String" class must be some other class and not java.lang.String. Did you write the API in question? Does it have a "String" class in one of its namespaces? Or perhaps you wrote a class named "String" and didn't put it in a package? If that's not the case, then contact the writer and ask them.
-
CompareTo(Comparable) cannot be applied to...
When I try to compile my set of files, while trying to create a priority queue, I get the following errors:
Lijst.java:53: compareTo(Comparable) in Comparable cannot be applied to (java.lang.Object)
if (lst == null || x.compareTo (lst.wrd) <= 0 ) {
^
Lijst.java:58: compareTo(Comparable) in Comparable cannot be applied to (java.lang.Object)
while (h.succ != null && x.compareTo (h.succ.wrd) > 0) {
^
Lijst.java:69: compareTo(Comparable) in Comparable cannot be applied to (java.lang.Object)
if (lst == null || x.compareTo (lst.wrd) < 0 ) {
^
Lijst.java:74: compareTo(Comparable) in Comparable cannot be applied to (java.lang.Object)
while (h.succ != null && x.compareTo (h.succ.wrd) > 0) {
^
Lijst.java:78: compareTo(Comparable) in Comparable cannot be applied to (java.lang.Object)
if (h.succ == null || x.compareTo (h.succ.wrd) < 0) {But x was typecasted to a Comparable in Lijst.java:
void voegIn (Object y) {
Comparable x = (Comparable) y;
if (lst == null || x.compareTo (lst.wrd) <= 0 ) {
zetVoor (x);
return;
}Why does Java forget that typecast???But that's why I've tried to typecast it to a
Comparable. Because the argument of the compareTo
function will be of type Toestand which implements
Comparable.
What's the alternative for this, if this is all
wrong??Looks like you'll need to cast both the reference to
the object whose method you're invoking and the
reference to the argument. Comparable foo = (Comparable)bar;
bar.compareTo((Comparable)lst.wrd); Or something like that.And of course this only works if lst.wrd points to an object that actually does implement Comparable. -
Weblogic.servlet.jsp.StaleChecker cannot be applied
Hi,
I am getting the following error when i try to access the web application deployed
on the weblogic 8.1 sp2 application server. The same works fine on weblogic 7.1.
Please let me know if any of you came across this problem.
C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_rttm_rttm\jsp_servlet\__login.java:49:
isResourceStale(java.lang.String,long,java.lang.String) in weblogic.servlet.jsp.StaleChecker
cannot be applied to (java.lang.String,long,java.lang.String,java.lang.String)
(No more information available, probably caused by another error.
Thanks in advance
-NagarajuMay be the weglogic.jar used in your web application is differ with the current
bea home's.
"Nagaraju" <[email protected]> wrote:
>
Hi,
I am getting the following error when i try to access the web application
deployed
on the weblogic 8.1 sp2 application server. The same works fine on weblogic
7.1.
Please let me know if any of you came across this problem.
C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_rttm_rttm\jsp_servlet\__login.java:49:
isResourceStale(java.lang.String,long,java.lang.String) in weblogic.servlet.jsp.StaleChecker
cannot be applied to (java.lang.String,long,java.lang.String,java.lang.String)
(No more information available, probably caused by another error.
Thanks in advance
-Nagaraju -
Cannot run program "keytool": java.io.IOException
Hi,
I would like to follow the procedure to change the master password
of glassfish server hosting APEX listener
using the change-master-password subcommand, but the utility keytool
is not found:
glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config> /opt/glassfish3/bin/asadmin
/opt/glassfish3/bin/asadmin
Use "exit" to exit and "help" for online help.
asadmin> change-master-password mydom01
Enter the current master password> changeit
Enter the new master password> changedit
Enter the new master password again> changedit
Cannot run program "keytool": java.io.IOException: error=2, No such file or directory
Command change-master-password failed.
asadmin>
Command multimode failed.
glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config> which java
/usr/bin/java
glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config>
All of glassfish is running fine apart from this.
keytool could be found in /usr/java/latest/bin/keytool.
Do we need to have this in the path? There is no requirement in the
install guide for this, nor did the RPM installation adjust the system
path accordingly.
Hopefully someone can tell my how things ought to be regarding keytool?
Thanks, TomHi Tom,
the procedure to change the master password of glassfish server hosting APEX listener... sounds more like a GlassFish-related topic to me. I guess you'd get the best answers for such questions in a GlassFish-related forum...
For what it's worth, I'll try my best anyway:
Cannot run program "keytool": java.io.IOException: error=2, No such file or directoryThis seems to be a pretty clear error message: keytool , which is probably used to manage the keys for GlassFish users, wasn't found. This means, you're either running on an OS that is not officially certified for GlassFish, or you GlassFish hasn't been configured properly.
You ran
glassfish@ahost:/opt/glassfish3/glassfish/domains/mydom01/config> which java
/usr/bin/java... which indicates you assume your GlassFish is running without JAVA_HOME being set. If that's true, I'd begin to setup you GlassFish properly starting with that parameter.
Anyway, you also found out that
keytool could be found in /usr/java/latest/bin/keytool.... which is not +/usr/bin+ and hence probably not in the global search path of the user on whose behalf your GlassFish is running. So, you could either create a link-set[*] for +/usr/bin/keytool+ to (finally) point to +/usr/java/latest/bin/keytool+, or you setup JAVA_HOME to be +/usr/java/latest+ .
[*] Note that depending on your OS there might be more than one stage of indirection, e.g. my Ubuntu has +/usr/bin/java+ pointing to +/etc/alternatives/java+ which is pointing to +/usr/lib/jvm/java-6-sun/jre/bin/java+ where +/usr/lib/jvm/java-6-sun/+ is pointing to the directory containing the actual JDK to be used. You'll probably find something like that on your system as well. My Ubuntu box has a link for +/usr/bin/keytool+, so I get that when running "which keytool".
Do we need to have this in the path? There is no requirement in the install guide for this, nor did the RPM installation adjust the system path accordingly.Again, this is not a GlassFish forum.
I hope my hints help you solve your problem. If they don't, please choose the appropriate forum for your next post on that topic. And I guess, giving some more information on your OS and how you manage your JDK (and which version you use) will help people there to help you.
Thanks,
Udo -
Method cannot be applied error
I am having trouble compiling my application because it says a sorting method I want to use cannot be applied to the array I want to sort.
I have a class that was supplied by my instructor that contains a constuctor for an object called "automobile". This constructor has 4 args which are (string, string, double, double). The strings are for make and model of vehicle and the doubles are for gas tank size and range on a full tank. The constructor takes the double values and calculates the miles per gallon. In my application I am making an array of 15 vehicles called "automobile". When I print to an outpuBox the list of vehicles, everthing looks fine. The problem is I need to sort the array by the miles per gallon. Now I have made a seperate class the contains my "cocktail shaker sort", but when it seems that the array of vehicles I created cannot be used in the args of the sort method. Any help would be greatly appeciated. This thing was due a week ago and I've been pulling my hair for 3weeks.
The error message is:
Autos.java:64: cockTailSort(int[]) in CockTail cannot be applied to (Automobile[])
CockTail.cockTailSort(automobile);
1 error
Below is my application and following that will be the cocktailshaker class.
import javabook.*;
import java.text.DecimalFormat;
class Autos
public static void main (String[] args){
MainWindow mainWindow;
InputBox inputBox;
OutputBox outputBox;
MessageBox messageBox;
ResponseBox responseBox;
String modelName, modelType;
double gasTankCapacity, rangeOnFullTank;
int count;
mainWindow = new MainWindow ("Automobile input");
inputBox = new InputBox (mainWindow);
outputBox = new OutputBox (mainWindow);
responseBox = new ResponseBox (mainWindow );
messageBox = new MessageBox (mainWindow);
messageBox.setVisible (false );
mainWindow.setVisible ( true ) ;
outputBox.setVisible ( true ) ;
Automobile[] automobile = new Automobile [3];
int i=0;
count =1;
for (i = 0 ; i < automobile.length ; i ++){
modelName = inputBox.getString ("Enter Model Name for vehicle #" + count);
modelType = inputBox.getString ("Model Type for #" + count);
gasTankCapacity = inputBox.getDouble("Gas capacity for #" + count);
rangeOnFullTank = inputBox.getDouble("Fulltank range for #" + count);
automobile[ i ] = new Automobile ( modelName, modelType,gasTankCapacity,rangeOnFullTank );
count ++;
CockTail.cockTailSort(automobile);
for (i = 0 ; i < automobile.length ; i ++){
automobile.displayAutomobile(outputBox);
Here is the sort:
import javabook.*;
class CockTail
public CockTail()
public static void cockTailSort (int a [] )
boolean sorted = false;
int top = a.length -1, bottom =0;
for (int pass =1; bottom < top && !sorted; pass ++)
sorted = true;
if (pass % 2 != 0) // odd # passes
for (int i = bottom; i < top; i ++)
if (a[i] > a[i + 1])
sorted = false;
int temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
top --;
else // even-numbered passes
for (int i = top; i > bottom; i--)
if (a[i - 1] > a[i])
sorted =false;
int temp = a[i];
a[i] = a[i - 1];
a[i - 1] = temp;
bottom ++;Well I changed it to what you said and it didn't work. I really appreciate your though.
Here are the source codes :
import javabook.*;
import java.util.*;
import java.text.DecimalFormat;
class Autos
* Setting data members and constructors
public static void main (String[] args){
MainWindow mainWindow;
InputBox inputBox;
OutputBox outputBox;
MessageBox messageBox;
ResponseBox responseBox;
String modelName, modelType;
double gasTankCapacity, rangeOnFullTank;
int count;
mainWindow = new MainWindow ("Automobile input");
inputBox = new InputBox (mainWindow);
outputBox = new OutputBox (mainWindow);
responseBox = new ResponseBox (mainWindow );
messageBox = new MessageBox (mainWindow);
messageBox.setVisible (false );
mainWindow.setVisible ( true ) ;
outputBox.setVisible ( true ) ;
outputBox.printLine("This program will ask for data for 15 vehicles and ");
outputBox.printLine("calculate the Miles Per Galllon for each vehicle and ");
outputBox.printLine("compare the MPGs to be displayed in a sorted list in an outpuBox.");
outputBox.printLine("you will be asked to enter the vehicles model, model type");
outputBox.printLine("gas tank capacity and total range on a full tank.");
// create an automobile array
Automobile[] automobile = new Automobile [3];
* Loop for data inputs an array creation
int i=0;
count =1;
for (i = 0 ; i < automobile.length ; i ++){
modelName = inputBox.getString ("Enter Model Name for vehicle #" + count);
modelType = inputBox.getString ("Model Type for #" + count);
gasTankCapacity = inputBox.getDouble("Gas capacity for #" + count);
rangeOnFullTank = inputBox.getDouble("Fulltank range for #" + count);
automobile[ i ] = new Automobile ( modelName, modelType,gasTankCapacity,rangeOnFullTank );
count ++;
*Code for cocktail sort method call
CockTail.cockTailSort(automobile); // Error in code
* Display data and MPG's in outputBox
for (i = 0 ; i < automobile.length ; i ++){
automobile.displayAutomobile(outputBox);
Here is the cocktail shaker sort:
import javabook.*;
import java.util.*;
class CockTail
//public CockTail()
public static void cockTailSort (Automobile[] a )
boolean sorted = false;
int top = a.length -1, bottom =0;
for (int pass =1; bottom < top && !sorted; pass ++)
sorted = true;
if (pass % 2 != 0) // odd # passes
for (int i = bottom; i < top; i ++)
if (a[i] .compareto( a[i + 1])==1)
sorted = false;
Automobile temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
top --;
else // even-numbered passes
for (int i = top; i > bottom; i--)
if (a[i] .compareto( a[i - 1])==1)
sorted =false;
Automobile temp = a[i];
a[i] = a[i - 1];
a[i - 1] = temp;
bottom ++;
Here is what I know of the Automobile class:
// JBuilder API Decompiler stub source generated from class file
// Aug 6, 2002
// -- implementation of methods is not available
// Imports
import java.lang.String;
import javabook.OutputBox;
class Automobile {
// Fields
private String modelName;
private String modelType;
private double gasTankCapacity;
private double rangeOnFullTank;
private double milesPerGallon;
// Constructors
public Automobile() { }
public Automobile(String p0, String p1, double p2, double p3) { }
// Methods
public int compareto(Automobile p0) { }
public void displayAutomobile(OutputBox p0) { } -
Weblogic 10.3 error apache ListOrderedMap cannot be cast to java HashMap.
Hi All,
I'm having following code which is using spring(version: 2.0) dao
public Map<String, String> getEmplyeeMap() throws Exception {
StringBuffer query = new StringBuffer("");
query.append("select emp_name,dept_name from EMPLOYEE order by emp_no");
logger.info("Inside getEmplyeeMap...Query to be executed :"+query.toString());
Map<String, String> EmpMap = new LinkedHashMap<String, String>();
List<Map<String,String>> l_lstQueryRes = (ArrayList<Map<String,String>>)getJdbcTemplate().queryForList(query.toString());
logger.info("l_lstQueryRes:"+l_lstQueryRes);
if (l_lstQueryRes != null)
for (int l_iLoop = 0; l_iLoop < l_lstQueryRes.size(); l_iLoop++)
Map<String,String> l_mapRowData = new HashMap<String,String>();
l_mapRowData = (HashMap<String,String>)l_lstQueryRes.get(l_iLoop);
EmpMap.put(l_mapRowData.get("emp_name"), l_mapRowData.get("dept_name"));
}//End of for loop
}//End of if loop
logger.info("EmpMap list size is.." + EmpMap.size());
return EmpMap;
} //End of getEmplyeeMap
getting below error
org.apache.commons.collections.map.ListOrderedMap cannot be cast to java.util.HashMap
I'm thinking this problem is occurring because of jdk1.6 version, is anyone come across this problem?? This same working good in weblogic9.2 version.
Thanks advance.
Regards,
Sharath.user9222505 wrote:
Ok, thanks. So how do i determine where we are at since I have this "465"? How does that relate to a particular patch?
Logger@9214443 3.5.3/465I believe, you are on 3.5.3 unpatched, and if I correctly remember, after applying the 3.5.3 patch 4 it should like like 3.5.3p4/... or 3.5.3.4/... (don't remember which one)... You would have to download that patch from your Oracle Support website (whichever you use), and apply the patch to a pristine extracted directory of 3.5.3 according to instructions in the patch zip.
Starting with a recent version no more manual patching is necessary and you can download full distributions of patched versions from Oracle Support, but I don't think that applies to 3.5.3, yet (although it is possible that they recreated patch artifacts like that for earlir versions).
If you do not have a support contract then you cannot download a patch or patched versions. You can only download a new full release which always has any previously released patches incorporated, though 3.5.3 is the last 3.5 full release if I correctly remember... and 3.6 comes with code incompatibilities at a few places so it is not a drop-in replacement...
Best regards,
Robert -
Re: cannot be applied to (double,java.lang.String)
It's telling you what the problem is -- you're trying to pass a String in where a double is required. Java is a strongly typed language, which means that you can't expect types to change automatically into other types as needed.
You could, I suppose, parse the string, assuming that it holds a representation of a double. But if you look at the method in question, you'll see that it doesn't even use its second (double) argument.
So you should ask yourself:
1) should that method really take two arguments?
2) what is the second argument for, if I did use it?
3) what is the best type to represent the second argument?
(hint: with a name like "customerType", then an enum seems likely)
[add]
Too slow again.
Though I'll also add: please wrap any code you post in [code][/code] tags. It makes your code much easier to read.
Message was edited by:
paulcw> String n ;
n = JOptionPane.showInputDialog(null, "Enter Month No.:");
pow(double,double) in java.lang.Math cannot be
applied to (double,java.lang.String)Read the error diagnostic carefully: the compiler found a pow() method
in the Math class, but it takes two doubles as its arguments. You,
however, supplied a double and a String as the parameter types.
The method found by the compiler cannot be applied to your parameters.
hint: you have to convert that String to a double,
kind regards,
Jos -
Error messages! area(double, double) cannot be applied to ( )
I keep getting these error messages:
area(double,double) in Rectangle cannot be applied to ()
return "Area: " + Rectangle.area() + "\tCircumference: " + Rectangle.perimeter(); ^
perimeter(double,double) in Rectangle cannot be applied to ()
return "Area: " + Rectangle.area() + "\tCircumference: " + Rectangle.perimeter();
^
setSides(double,double) in Rectangle cannot be applied to (double)
R.setSides(input.nextDouble());
^
3 errors
Tool completed with exit code 1
Can anybody tell me why it is doing this? Thanks in advance!
import java.util.Scanner;
public class Rectangle
public double length;
public double width;
public Rectangle()
length = 0;
width = 0;
public double getSides()
return length;
return width;
public void setSides(double length, double width)
this.length = length;
this.width = width;
public double area(double length, double width)
double area = length * width;
return area;
public double perimeter(double length, double width)
double perimeter = (length * 2) + (width * 2);
return perimeter;
public String toString()
return "Area: " + Rectangle.area() + "\tCircumference: " + Rectangle.perimeter();
public static void main(String [] args)
Rectangle R = new Rectangle();
Scanner input = new Scanner(System.in);
System.out.println("Enter radius: ");
R.setSides(input.nextDouble());
System.out.println(R.toString());
}Looking at your code more, it looks like what you want to do when you call area is get the area of the Rectangle based on the length and width it already has stored, not what you pass it. So if you take out the parameters like this:
public double area() {
double area = length * width;
return area;
}It will use the member variables length and width to calculate area. -
Hi Friends,
I have simple req'.
i have one date filed in OAF page...if user has change the date filed..means if he incresed by 2 days..then i need to call one procedure..if not no need to call....
first am picking that date field to by uusing prepared stmt and putting in to one variable..like below
try {
ps1 = am.getOADBTransaction().getJdbcConnection().prepareStatement("SELECT -------");
ResultSet rs2 = ps1.executeQuery();
while (rs2.next()) {
schDate = rs2.getString(1);//storing the value
} catch (Exception e) {
throw OAException.wrapperException(e);
Next..am picking the current value like this(user can change the value) like below...
OAViewObject viewObj = (OAViewObject)am.findViewObject("simpleVO");
String currSchDate = (String)viewObj.getCurrentRow().getAttribute("iDate");
java.text.SimpleDateFormat dtFormat = new java.text.SimpleDateFormat ("MM/dd/yyyy");
StringBuilder date = new StringBuilder(dtFormat.format(currSchDate));
Then am comparing the values like below..
if (schDate.equals(date)) {
String outParamValue = "";
String secondOutParamValue = "";
but am geting the below error
## Detail 0 ##
java.lang.ClassCastException: oracle.jbo.domain.Date cannot be cast to java.lang.String
at xxuss.oracle.apps.abc.webui.xxPGCO15.processFormRequest(xxGCO15.java:594)
Appriciate any help...its very urgent
Regards
HarryInstead of :
String currSchDate = (String)viewObj.getCurrentRow().getAttribute("iDate");Try
String currSchDate = viewObj.getCurrentRow().getAttribute("iDate").toString();
-Anand -
Since I installed Java 7 update 51 accessing the EMC VNX Unisphere Console cause the following error: java.util.HashMap cannot be cast to java.awt.RenderingHints.
I rolled back to Apple Java 1.6 -005 now I am getting the following error: plug-in failure.
I think this is cused by the fact that the EMC console application has been written for java 7 and not java 6. Has anybody faced and solved the "java.util.HashMap cannot be cast to java.awt.RenderingHints." error ?Hi Yaakov,
The error is thrown from the eclipselink.jar:2.5.1 which is a JPA provider .
Is the above jar bundled in the Oracle Product you are working upon or was this downloaded from external site ?
If the jar is bundled with the Oracle Product, go ahead a log a SR with Oracle Support with Toplink product group to drill down on the issue, as the issue is happening internally or thrown by the Eclipselink implementation and we've no control....
Hope it helps!!
Thanks,
Vijaya -
I am looking at an issue with users not getting specific group policies.
After searching a number of client computers I found that the following error
The user '*' preference item in the 'User - 6th Form Students Policy {E03166E7-A848-48B5-AA93-97B848AA9C13}' Group Policy object did not apply because it failed with error code '0x80070003 The system cannot find the path specified.' This error was suppressed.
I can find the folder in the Sysvol folder on all of the domain controllers.
The issue with end users seems to be that the proxy settings for internet explorer is not being applied.
Potential problems?
one folder in sysvol entry is empty
\\<server>\SYSVOL\<domain.name>\Policies\{E03166E7-A848-48B5-AA93-97B848AA9C13}\User\microsoft\IEAK\LOCK
or is this our issue
The old method of configuring proxy settings to Internet Explorer 9 has changed?
https://support2.microsoft.com/kb/2530309?wa=wsignin1.0
http://thommck.wordpress.com/2013/11/08/the-new-way-to-configure-internet-explorer-proxy-settings-with-group-policy/Hi all
In administering this policy I am a little confused.
We have a policy that distributes proxy settings in the internet explorer maintenance settings section - however when opening this policy up in GPO editor the internet explorer maintenance section is not present.
I plan to apply the settings via User/preferences/control panel settings/ internet settings (or registry settings from article) however I am unable to edit the settings for internet explorer maintenance and these will persist. Ideas???? -
PSE 9.0.3 does not install. Error message "patch cannot be applied."
Manually install the download the update from below given link:-
For Mac:- http://www.adobe.com/support/downloads/detail.jsp?ftpID=5012
For Win:- http://www.adobe.com/support/downloads/detail.jsp?ftpID=5000
Download and install the update. -
Cannot install update 9.0.3 in my Photoshop Elements 9. Getting error msg "Patch cannot be applied". How can I correct?
Nobody can know. You are not offering system info or otehr details. Start by uninstalling and reinstalling the base program.
Mylenium
Maybe you are looking for
-
SAP NOTE 1606246 in Error - RFIDITVCL: 3000 Euro Communication Italy Legal
Hi Guys, I am working on italy legal requirement and implemented note 1606246,but as i have raised an OSS to sap they have said they are still in the process of implementing the changes to the note.' Can you all please let me know what is all your st
-
What would these points and lines be?
I saw someone use InDesign and they had blue lines and solid points set between their InDesign objects in a document. (to determine the placement of objects and text, probably.) But I have never seen this before! They were certainly not guides or fra
-
how can i unlock my iphone 3
-
Just upgraded to Lightroom5 from lightroom 3.6
I have just upgraded from lightroom 3.6 to lightroom 5 and the develop tab setting are as lightroom 3? any ideas what to do? Thanks,
-
Since I bought my Motorola bluetooth, all notifications while connected are played through the headset and not the phone's speaker. This wasn't a problem on my old bluetooth set. Is there a way to change this where when I'm connected, the notificatio