JAVA Compilation program -
public class findtop { private int[] numbers; public findtop(int[] numbersarg){ this.numbers = numbersarg; } public int findhigher(int lowerindex, int higherindex){ int top = this.numbers[lowerindex]; for(int = lowerindex; <= higherindex; i++){ if (top < this.numbers[i]) top = this.numbers[i]; } return top; } public static void main(string[] args) { int mynumbers[] = {10, 5, 2, 4, 8}; findtop numbers = new findtop(mynumbers); system.out.println( numbers.findhigher(1, 4)); } } as i'm new java, wasn't able code, trying execute, error :
could suggest me going wrong. compilation info
main.java:1: error: class findtop public, should declared in file named findtop.java public class findtop {
in java, have name file same public class. in case, file saved should called findtop.java capitals , all.
each source file can contain 1 public class. source file's name has name of class. convention, source file uses .java filename extension (a tail end of file name marks file being of particular type of file.)
for capitalization part, make habit always capitalize file name same class name. (findtop , not findtop). on systems, won't matter, on many throw errors if capitals different.
here more explanation.
Comments
Post a Comment