×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
I'm very much a beginner with Java and I'm having a problem
understanding how scope works.
In MyPgm below, I get an error saying that fontDetail in the setFont()
method is undefined.
From what I've read in the documentation, a reference within the
setFont() method to a field within the same class but outside the method
is allowed.
Is fontDetail a field or a variable? Is it only visible within the
main() method, but not within any methods defined in main()?
public class MyPgm {
public static void main (String[] parameters) {
if (parameters.length == 2) {
String FONTtype = parameters[0];
String fontDetailSize = parameters[1];
wb = new SXSSFWorkbook();
Font fontDetail = wb.getFontAt((short)0);
setFont();
} else {
System.out.println("Wrong number of parameters.");
System.exit(1);
}
System.exit(0);
public static void setFont() {
fontDetail.setFontName(FONTtype); <<=====fontDetail undefined
}
}
}
--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx
pdow@xxxxxxxxxxxxxx /
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.