Netbeans - Method Cannot Be Applied To Given Types

Sep 23, 2014

Here is my code:

import java.util.*;public class DebugSix {
public static void main(String[] args) {

ArrayList<String>products = new ArrayList();
products.add("shampoo");
products.add("moisturizer");
products.add("conditioner");
Collections.sort(products);

[Code] ....

I am using netbeans and getting errors for display(); and size(); it is telling me the errors are :

for the display error, "method display in class DebugSix cannot be applied to given types;
display();" and for the size() is : "cannot find symbol System.out.println("
The size of the list is " + size());"

View Replies


ADVERTISEMENT

Form Initialization - Method Cannot Be Applied To Given Types

Apr 21, 2015

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package BaiVeNha;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.DefaultTableModel;

[Code] ....

View Replies View Related

Method GetRadius In Class Circle Cannot Be Applied To Given Types

Sep 15, 2014

I am getting an error with my code. How to fix it.

import java.util.Scanner;
import java.util.*;
/*
* FileName: Circle.java
*/

public class Circle {
private double PI = 3.14159;
private double radius;
public Circle()
{
radius = 0.0;

[Code] ....

This is the error i am receiving:

Circle.java:78: error: method getRadius in class Circle cannot be applied to given types;
System.out.println("A circle with a radius of " + circle.getRadius() + " will have an area of " + circle.getArea() + " , a diameter of " + circle.getDiameter() + " and a circumference of " + circle.getCircumference());
^
required: double
found: no arguments
reason: actual and formal argument lists differ in length
1 error

View Replies View Related

Method Setradius In Class Circle Cannot Be Applied To Given Types

Sep 7, 2014

I'm new to programming and I have an assignment due in java class. Here is the error code:

TestCircle.java:10: error: method setradius in class Circle cannot be applied to given types;
circle1 = inputCircle.setradius();
^
required: double
found: no arguments
reason: actual and formal argument lists differ in length

And here is my code:

import java.util.Scanner;
public class TestCircle
{
public static void main(String[] args)
{
double circle1;
double circle2;
double circle3;
Circle inputCircle = new Circle();

[Code] ......

View Replies View Related

Constructor In A Class Cannot Be Applied To Given Types

Feb 13, 2015

This code works

public class RedShapeDecorator extends ShapeDecorator {

public RedShapeDecorator(Shape decoratedShape) {
super(decoratedShape);
}

Below results in an error

public class RedShapeDecorator extends ShapeDecorator {

protected Shape decoratedShape;
public RedShapeDecorator(Shape decoratedShape) {

this. decoratedShape=decoratedShape;

}

So I am guessing that if you extend class, you should use super to pass objects?

View Replies View Related

Error Constructor Class Cannot Be Applied To Give Types

Jun 12, 2014

I'm getting an error on line 51 and don't know what it means?

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/ 
package million;
import java.util.Scanner;
import java.util.ArrayList;

[code].....

View Replies View Related

Declaring Class In Main Class - Constructor Cannot Applied To Given Types

Aug 1, 2014

So i declared a class in main class but it seems there's error when i compile:

constructor xx in class xx cannot applied to given types

This is my java class:

public class trainer extends person{
String classType;
public trainer(String name, String gender, String address, int id, String classType) {
super(name,gender,address,id);
this.classType=classType;

[Code] ....

And this is the way i declared in main class:

trainer tr = new trainer();

And what i want to do is:

tr.toString();

View Replies View Related

Constructor Jframe In Class Jframe Not Be Applied To Types

Jun 22, 2014

So I have this line of code...

ioexception11.addChoosableFileFilter(new Jframe());

And when I compile it gives me...

error: constructor Jframe in class Jframe cannot be applied to given types;
ioexception11.addChoosableFileFilter(new Jframe());

View Replies View Related

Sort Strings In Alphabetical Order - Method Not Being Applied

Jan 21, 2014

I'm doing an exercise we're you're supposed to sort strings in alphabetical order, without importing anything , not using the Arrays.sort() method.

I think I got the method down partially right, or it is on the right track, but it is completely not being applied to my answer. All it prints out in the console is the actual String array twice, without sorting anything.

public class arrayofstrings {
public static void sort(String[] a) {
String temp= "";
int min;
int i= 0;
for (int j=0; j<a.length-1; j++) {

[Code] ....

View Replies View Related

Method Values For Enum Types

Nov 21, 2014

What class does method Planet.values() in the code below belong to? I thought it belongs to java.lang.Enum but when I could not see it in Java API 7.

package enumeration;
public class EnumTest {
public static void main(String[] args) {
//Planet myPlanet = Planet.EARTH;
// Check arguments supplied
if (args.length != 1) {
System.err.println("Usage: java EnumTest <earth_weight>");
System.exit(-1);

[code]....

View Replies View Related

How Many Types Of Inputting Method In Java

Jun 30, 2014

how many types of inputting method in java?can you explain with examples?

View Replies View Related

Create 4 Types Of Strings Under Same Method But Only Draw One At A Time

May 11, 2015

I am having trouble with methods. What I want to do is be able to create 4 types of strings under the same method, but only draw one of them at a time.

i.e

UI.initialise;
UI.addButton ("pipe", this::drain);
public void drain(){
this.pipe ("pipe1");
this.pipe ("pipe2");

[Code] ....

When I press the button "drain" it will print=

pipe1

pipe2

pipe3

pipe4

I am having a lot of difficulty just printing one out after each time I press drain.

"drain"

pipe1

"drain"

pipe2 etc..

View Replies View Related

Using Primitive Data Types To Overload Sound Method

Jun 29, 2014

Trying to find a way to use primitive data types to overload sound()method. I can't seem to warp my head around using an int or a double to overload the method. And if I did, how do you call them in the main afterwards?

View Replies View Related

ArrayList Contains Method Does Not Work On User-defined Data Types

Sep 1, 2014

I am trying to remove the duplicate elements from ArrayList using .contains() if elements are primitive datatype it works but user-defined datatype does not work.

public class UserBean {
String name;
String address;
public String getName() {
return name;

[code]....

View Replies View Related

Netbeans - Unable To Debug Equals Method

Mar 11, 2015

I need to debug the equals method implementation of a class I've made, but I cannot for the life of me get Netbeans' debugger to step into it. I can step into other methods from the class (most of which implement the methods in an interface) that are called in the main method (just like the equals method). I've tried...

-Disabling all the step filters
-Clearing the Netbeans cache
-Moving the call to the equals method out of the if statement it's in and just calling it as its own statement
-placing breakpoints within the equals method as well as on the call to the method
-placing a method breakpoint on the overridden equals method in addition to the other locations
-Using the shift-F7 version of the step into command

I'm using Netbeans 8.0.1 (I don't know if this is the latest version, but the last time I tried to update everything died and I had to completely remove NB and reinstall it) and JDK 8u05 (I think).

View Replies View Related

Netbeans 7.3 - When Adding Print Code Main Method Is Not Recognized

May 13, 2013

I am writing a program in the GUI Builder and found that when I add code to print user input from text fields to a text file, the main method is no longer recognized. It throws all kinds of errors.

I have been able to get the code to work separately in a project file. Also, have been able to print to the console.

View Replies View Related

JSF :: Rich Faces Skin Not Applied

Aug 11, 2014

I am retrieving data in <rich:datatable> , but the default skin color is not being applied in my page. My web.xaml is as below

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>richFacesApp</display-name>

[Code] ....

I am using tomcat 7.0 and Richfaces 4.0

View Replies View Related

I/O / Streams :: Escaping Double Quotes Be Applied To Reading From A File?

Sep 26, 2014

If I'm using an xml file and the piece of data I want from the file looks like Staff id ="Test";

Is it something like this? Only seen two examples of it but I'm not sure they were reading from a file like myself.

Staff id = """ + Test + """;

View Replies View Related

JavaFX 2.0 :: Combobox - Visible Count Row Not Applied And Doesn't Change

Oct 15, 2014

I have noticed a strange behavior of Combobox element. The number of visible rows is not the same established by setVisibleRowCount() method. It happens when changing the items list dynamically. The following example reproduces it. I think it is Javafx 8 bug. I have tried unsuccessfully to trigger some event indirectly to refresh the combobox drop down.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class TestComboBox extends Application {
    private int count;

[Code] .....

View Replies View Related

Overloading With Primitive Types?

Jan 22, 2015

Why the following is happening.

For the below code, when I execute it, it prints

Short method 10 //result 1
Sub class short method 10 //result 2

Which is as expected but if I comment out line 3, then it prints

Integer method 10 //result 3
Integer method 10 //result 4

I can understand result 3 is because of an upcast from short to int, since FunWithOverloading will not have a overloaded method with short now. However, what is happening with result 4? Shouldn't it call methodA of the subclass with the argument type short? If its because I have declared the reference variable, derived, of the type FunWithOverloading, then how come the first result correctly picks the overloaded method of the sub class?

class FunWithOverloading{
void methodA(int x){System.out.println("Integer method " + x);}
void methodA(short x){System.out.println("Short method " + x);} //line 3
} class OverloadedSubClass extends FunWithOverloading{
void methodA(short x){System.out.println("Sub class short method " + x);}

[Code] ....

View Replies View Related

Initializing Arrays Of Various Types

Sep 18, 2014

For basic arrays, we can directly combine declaration and initialization as E.g: int[] num= new int[2]

But can we do this do for forming class object arrays? like

class stu
{
.....
}
stu[] s=new stu[2]
????

View Replies View Related

How To Create And Re-use Object Types

Mar 17, 2014

how objects relate to classes and how you can create and re-use object types.on that point, but this has me baffled. I most certainly do not have a firm grasp yet on passing things to and from methods that just makes my head hurt. SO anyway I tried out one of the code examples:

/* ElectricGuitar.java */
class ElectricGuitar {
String brand;
int numOfPickups;
boolean rockStarUsesIt;

[code]...

But I just realized this thing has no main method and only one class defined.....so I guess I just tried to compile.

View Replies View Related

Incompatible Types For Fname

May 6, 2014

import java.util.Scanner;
class potatoes {
public static void main(String[] args){
Scanner user = new Scanner(System.in);
String fname;
fname = user.nextLine;
String newfname = fname.substring(0, 3);
System.out.println(newfname);
}
}

This bit of code isnt working, it has something to do with incompatible types for fname

View Replies View Related

Generic Types In Java

Apr 1, 2014

I am trying to understand the concept of Generics in java. In the introduction to Generic Types, this example is given:

Java Code: public class Box {
private Object object;
public void set(Object object) { this.object = object; }
public Object get() { return object; }
} mh_sh_highlight_all('java'); "Since

Since its methods accept or return an Object, you are free to pass in whatever you want, provided that it is not one of the primitive types." - I understand this.But then it has been changed to a generic class:

Java Code: /**
* Generic version of the Box class.
* @param <T> the type of the value being boxed
*/
public class Box<T> {
// T stands for "Type"
private T t;

public void set(T t) { this.t = t; }
public T get() { return t; }
} mh_sh_highlight_all('java'); "

As you can see, all occurrences of Object are replaced by T. A type variable can be any non-primitive type you specify: any class type, any interface type, any array type, or even another type variable."We can use any type in place of an Object, because Object is a superclass of all classes. But T (or any other class) is not a superclass of all classes. So how do we justify any class being used in place of a random T or any other class?

View Replies View Related

Wrappers And Primitive Types

Feb 23, 2015

I've got a question to ask.

public class AutoBoxingExample {
public void add(Integer intVal){
System.out.println("Wrapper");
}
public void add(int value){
System.out.println("Primitive");
}
public static void main(String[] args) {
AutoBoxingExample auto = new AutoBoxingExample();
auto.add(12);
}
}

The output is "Wrapper". What would be the reason behind it?

View Replies View Related

Change Variable Types Accordingly

Mar 14, 2014

GoodEmployee is defined who has ALL the following properties:

He should be married.
He should have 2 or less than 2 children.
His middle name should start with "k" but not end with "e"
The last name should have more than 4 characters
The character "a" should appear in the last name at least two times.
The name of one of his children should be "Raja"

Write a method:

boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames);

isMarried true if the employee is married.
noOfChild the number of children of the employee.
middleName the middle name of the employee
lastName the last name of the employee.
childNames the array of the names of the children of the employee

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved