+ 2

Can somebody fix this code for me pleasei .......get this error;illegal static declaration in inner class Mine

package ian; public class cudi { void ian(String j){ System.out.println(j); } int g,v; int ian(int h,int k){ h=g; k=v; int c=g/v; {System.out.println(c);} } class Mine{ public static void main(String args[]){ cudi bn=new cudi(); bn.ian("ian"); bn.ian(56,8); } } }

9th Dec 2017, 8:24 AM
Ian
Ian - avatar
11 Réponses
+ 7
//Can somebody fix this code for me pleasei .......get this error;illegal static declaration in inner class Mine //Code Fixed //package ian; This line causes an error public class cudi { void ian(String j){ System.out.println(j); } int g,v; void ian(int h,int k){ g= h; //not h=g; v= k; //not k=v; else you will have division by zero error int c=g/v; {//This curly brace not necessary System.out.println(c);} }//This curly brace also not necessary } class Mine { public static void main(String args[]){ cudi bn=new cudi(); bn.ian("ian"); bn.ian(56,8); } }
9th Dec 2017, 8:56 AM
David Akhihiero
David Akhihiero - avatar
+ 5
Copy my code and use it like that or try to match mine. Better yet put ur code in playground and put the link here
9th Dec 2017, 9:22 AM
David Akhihiero
David Akhihiero - avatar
+ 4
Did u modify my code?
9th Dec 2017, 9:19 AM
David Akhihiero
David Akhihiero - avatar
+ 4
Alrighty
9th Dec 2017, 11:29 AM
David Akhihiero
David Akhihiero - avatar
+ 4
What IDE are u using?
9th Dec 2017, 11:29 AM
David Akhihiero
David Akhihiero - avatar
+ 2
Thanks bruh....but my compiler prints out the same error message
9th Dec 2017, 9:18 AM
Ian
Ian - avatar
+ 1
i made changes to existing code
9th Dec 2017, 9:21 AM
Ian
Ian - avatar
+ 1
the code is okay....my compiler is bewitched 😂😂it says class cudi is public and should be declared in a file named cudi.java
9th Dec 2017, 9:25 AM
Ian
Ian - avatar
+ 1
//Can somebody fix this code for me pleasei .......get this error;illegal static declaration in inner class Mine //Code Fixed //package ian; This line causes an error //public//if i delete this it works class cudi { void ian(String j){ System.out.println(j); } int g,v; void ian(int h,int k){ g= h; //not h=g; v= k; //not k=v; else you will have division by zero error int c=g/v; {//This curly brace not necessary System.out.println(c);} }//This curly brace also not necessary } class Mine { public static void main(String args[]){ cudi bn=new cudi(); bn.ian("ian"); bn.ian(56,8); } }
9th Dec 2017, 9:28 AM
Ian
Ian - avatar
+ 1
Sorry......its cppdroid
10th Dec 2017, 9:05 PM
Ian
Ian - avatar
0
Java n IDE android app
10th Dec 2017, 8:21 PM
Ian
Ian - avatar