Reputation: 1
So I am attempting a project with a fake credit card to get a feel of coding but I am at a stop because the code I input gives me "cannot find symbol" errors. Am I doing this wrong?
class Main{
float balance;
String name;
public void card(String name, float balance){
this.name = name;
this.balance = balance;
}
public static void main(String[] args){
card test = new card("Name", 3000.0);
System.out.printlm(test);
// Card cards = new Card();
// cards.example();
}
}
This is the output:
Main.java:12: error: cannot find symbol
card test = new card("Name", 3000.0);
^
symbol: class card
location: class Main
Main.java:12: error: cannot find symbol
card test = new card("Name", 3000.0);
^
symbol: class card
location: class Main
2 errors
compiler exit status 1
Upvotes: 0
Views: 37
Reputation: 191725
You passed the parameters fine, but your class constructor name must match the class and have no return type (remove void)
Classes should also always start with a capital letter
public class Card {
float balance;
String name;
public Card(String name, float balance){
this.name = name;
this.balance = balance;
}
public static void main(String[] args){
Card test = new Card("Name", 3000.0);
System.out.println(test.name);
}
}
This should be saved as Card.java
Upvotes: 4