•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 423,575 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,476 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 887 | Replies: 2 | Solved
![]() |
•
•
Join Date: Nov 2007
Posts: 14
Reputation:
Rep Power: 1
Solved Threads: 0
Can anybody tell me why I keep getting this error?
Am I mixing a class with a method? This is just a small program that simulates a TV. I'm trying to pass a number (chanel) to a method that tells the user that they are now watching chanel (whatever number I passed)...
Asig02_Attempt2.java:37: <identifier> expected public void sincronizarCanal(canal)
Am I mixing a class with a method? This is just a small program that simulates a TV. I'm trying to pass a number (chanel) to a method that tells the user that they are now watching chanel (whatever number I passed)...
import java.util.Scanner;
class Televisor
{
int canales,
volumen,
canal,
vol;
public Televisor()
{
canales = 5;
volumen = 10;
}
public void encender()
{
System.out.println("Televisor Encendido.");
}
public void apagar()
{
System.out.println("Televisor Apagado. Adios...");
}
public void sincronizarCanal(canal)
{
System.out.println("El canal ha sido sincronizado al canal" + canal);
}
public void ajustarVolumen()
{
System.out.println("El volumen ha sido ajustado.");
}
}
public class Asig02_Attempt2
{
public static void main(String arguments[])
{
Scanner input = new Scanner( System.in );
Televisor myTVSet = new Televisor();
myTVSet.encender();
System.out.print("Sincronizar al canal --> ");
myTVSet.canales = input.nextInt();
myTVSet.sincronizarCanal(myTVSet.canales);
System.out.print("\n");
System.out.print("Ajustar el volumen a --> ");
myTVSet.volumen = input.nextInt();
myTVSet.ajustarVolumen();
myTVSet.apagar();
}
}•
•
Join Date: Jan 2008
Posts: 1,747
Reputation:
Rep Power: 8
Solved Threads: 217
You are not telling the compiler what type "canal" is. I am guessing that "canal" is an integer, but you don't specify this:
If canal is an integer, you should change it to this:
However, this also won't work since you have a data member CALLED "canal". If it is the data member "canal" you are intending here, then don't pass the function anything, like this:
I'm not exactly sure what you are trying to do. It looks like you ARE trying to pass the function something. If so, if it is an integer, which appears to me to be your intent, I would rename it to some other name that is not the name of a data member, and place an "int" in front of that variable name, like this:
public void sincronizarCanal(canal)
If canal is an integer, you should change it to this:
public void sincronizarCanal(int canal)
However, this also won't work since you have a data member CALLED "canal". If it is the data member "canal" you are intending here, then don't pass the function anything, like this:
public void sincronizarCanal()
I'm not exactly sure what you are trying to do. It looks like you ARE trying to pass the function something. If so, if it is an integer, which appears to me to be your intent, I would rename it to some other name that is not the name of a data member, and place an "int" in front of that variable name, like this:
public void sincronizarCanal(int someIntegerName)
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- how can i solve error (Java)
- Program does not recognize actual input = expected output (C++)
- DataSource on windows mobile 6 (cant connect to sqlce database file [sdf]) (VB.NET)
- getting error msg <identifier > expected (Java)
- I created another Stack that tells if word is palindrome, need help (Java)
- Run-time Error when printing Array Contents. (C)
- Constructor (Java)
- I cant correct these two errors (C++)
- problems accessing class instances (Java)
Other Threads in the Java Forum
- Previous Thread: Help with Java Errors
- Next Thread: best Struts book



Linear Mode