0

java says int but no ints

Hello, i have this problem, im trying to do abstract maths in java, it keeps saying int cannot be dereferenced, but all my vars r doubles. primitive methods length and indexof.

31st Oct 2021, 7:16 PM
AW4
AW4 - avatar
5 odpowiedzi
+ 2
Its better to show code.. That's not enough information to identify problem.. Pls add code here...
31st Oct 2021, 7:17 PM
Jayakrishna 🇮🇳
+ 1
import java.util.Scanner; class stoic{ public void cantorsum(){ double n=0, k=0, p=0, b=0, c=0, nexn=0, cantden=0,y=0; Scanner scan=new Scanner(System.in);//add scanner object System.out.println("enter a num sequence for b then press enter"); b=scan.nextDouble(); System.out.println("enter a num less than 5 then press enter"); c=scan.nextDouble(); if(n==n){n=n;if(b==b){b=b;}if(i==i){i=i;}//no use of this. String[]b2=Double.toString(b).split("\\."); n=b2[0].length();nexn=n+1;cantden=Math.pow(c,nexn); double[]cantor=new double[(int)(b/cantden)];//need cast to int for(int i=0;i<cantor.length;i++){ //(1) i must be int type. and there is no n.length() function (n id double type value not string or array) may you mean cantor array length y=cantor[i]+cantor[i-1]; } System.out.println(y);} } public static void main(String[]args){ stoic s=new stoic(); //s.choosecoin(); s.cantorsum(); } } //you are not added full code, just tried to remove errors to run code, //Hope it helps...
5th Nov 2021, 12:34 PM
Jayakrishna 🇮🇳
+ 1
Your code is not readable. May you copy pasted from a net sourse. Copy into playground and save link here. Add detail description of errors you getting for more information if any need...
5th Nov 2021, 12:40 PM
Jayakrishna 🇮🇳
0
//2. public void cantorsum(){ double n=0;double k=0;double p=0; double b=0;double c=0;double nexn=0;double cantden=0;double y=0;double i=0; System.out.println("enter a number sequence for b then press enter");b=scan.nextDouble(); System.out.println("enter a num less than 5 then press enter");c=scan.nextDouble(); if(n==n){n=n;if(b==b){b=b;}if(i==i){i=i;} String[]b2=Double.toString(b).split("\\."); n=b2[0].length();nexn=n+1;cantden=Math.pow(c,nexn); double[]cantor=new double[b/cantden]; for(i=0;i<n.length();i++){y=cantor.indexOf[i]+cantor.indexOf[i-1];} System.out.println(y);} } public static void main(String[]args){stoic s=new stoic(); //s.choosecoin(); //s.cantorsum();
3rd Nov 2021, 4:39 PM
AW4
AW4 - avatar
0
nobody?
5th Nov 2021, 12:16 AM
AW4
AW4 - avatar