Identifier expected error when calling a method in java
The code
CalibInit(checkboxWidget,hist1D);
that is on a line of its own is not inside any of your methods. The compiler assumes that this is a new method declaration which is probably not what you want.
Side note:
It is not recommended to have methods starting with a upper case character: "Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized." from Code Conventions for the Java Programming Language
Resizing an ImageIcon
You need to put your code in a method, not directly in the class definition.
Try this for instance:
import java.awt.Image;
import javax.swing.ImageIcon;
public class Images
{
public static void main(String[] args) {
ImageIcon welcomeImage = new ImageIcon("WelcomeImage.PNG");
Image image = welcomeImage.getImage();
Image newImage = image.getScaledInstance(750, 500, java.awt.Image.SCALE_SMOOTH);//The error appears on this line
welcomeImage = new ImageIcon(newImage);
}
}
Syntax error on token close, Identifier expected after this token
Your
input.close();
at the end of the class is not in a method, this is not allowed in Java.
You need to move this to your main
method. It should probably go after the end of your while
loop as you have finished with input at that point:
} //END WHILE
input.close();
System.out.printf("\n%-30s%30s\n", "Total Number of Transactions", totalTrans);
Once you have done this you will find there are other compile errors which Eclipse can only detect when you have fixed the first error.
System.out.print( ); syntax error on token ., @ expected after this token
You need to put the code inside a method:
public class enc {
//The Look-Up Table with the position of all the available characters
public static final String LUT="*, .abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Input the sentence you want to encode.");
String s= sc.nextLine();
}
}
Related Topics
Overriding Object.Equals VS Overloading It
Java.Lang.Noclassdeffounderror: Org.Slf4J.Loggerfactory
Calling Getters on an Object VS. Storing It as a Local Variable (Memory Footprint, Performance)
Cannot Instantiate the Type List<Product>
Exact Difference Between Charsequence and String in Java
How to Make Cartesian Product with Java 8 Streams
Stringbuilder/Stringbuffer VS. "+" Operator
How to Convert an Integer to Localized Month Name in Java
Comparing the Values of Two Generic Numbers
How to Use Collections.Sort() in Java
How to Create an Instance of Inner Class Using Java Reflection
How to Intercept a Method Invocation with Standard Java Features (No Aspectj etc)
Scheduledexecutorservice Exception Handling
How to Set Up Default Schema Name in JPA Configuration
Eclipse/Maven Error: "No Compiler Is Provided in This Environment"