0

Java: getting error in line 15

import java.util.*; class lab1 { public static void main(String[] args) { String quote[] = {"hi","hello","Good Morning"}; Random r = new Random(); int a = Math.abs(r.nextInt()%3); System.out.println(quote[a]); Date d = new Date(); System.out.println("Today's date: "+d); System.out.println("Enter a Value for n: "); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Fib f = new Fib(); f.fibo(n); } class Fib{ public static void fibo(int num) { int a =0; int b = 1; int c = 0; System.out.println(a); System.out.println(b); for(int i =0;i<=num;i++) { c=a+b; System.out.println(c); a=b; b=c; } } } }

2nd Aug 2022, 1:22 AM
Zane Vijay Falcao
Zane Vijay Falcao - avatar
1 Odpowiedź
+ 4
you are declaring Fib class inside lab1 class The easy correct is to move Fib outside lab1 class delete last } add } here: f.fibo(n); } } // added class Fib{
2nd Aug 2022, 2:26 AM
zemiak