Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have the below one line of code:
variableDoubleValue = ((10*variableDoubleA) + (6.25*variableDoubleB) – (5*variableByteC) + 5);
How can I write it in a Java understandable code?
From what I infer from your question, you want a Java-language based variable declaration and assignment.
Well, if this is the case, then the result will be :-
//public class MathemathicalExpression{
// public static void main(String[] args){
// Double A=some_value,B=some_value,Value=0; considering A,B and Value to be of type Double
// Byte C=some_value; considering C to be of type Byte.
Value = 10 * A + 6.25 * B - 5 * C + 5;
// }
//}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I don't know why my defined function is not working smoothly.
in this I am trying to build a function to convert a binary number to a decimal number
public class binarrytodec {
public static void bintodec(int n){
int p=0;
int dec=0;
while(n>0){
int ld=n%10;
dec = dec + (ld*(int)Math.pow(2, p));
p++;
n=n%10;
}
System.out.print(dec);
}
public static void main(String args[]) {
bintodec(1110001);
}
}
% is not division, it's a remainder operation - it shows how much is left after integer division. 1 % 10 == 1. Thus your n is never becoming 0, and your code enters an infinite loop.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am trying to convert the following Java code into swift, but I do not know about this data structure new (int start, int end)[input. length], any guidance would be appraciated.
public override void collection_entries(int[] input)
{
var ranges = new (int start, int end)[input.length];
}
In swift, you should use a Range().
let start = 0
let end = 6
var ranges = Range(start...end)[input.count]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Why is this giving me 10 as output, rather than an error?
public class A {
static int a = m1();
static int m1(){
return 10;
}
public static void main(String args[]) {
A a1 = null;
System.out.println(a1.a);
}
}
Because compiler is so intelligent here,it basically replaces
System.out.println(a1.a);
with
System.out.println(A.a); //The name of your class 'A'
Because a is a static variable, so the reference to A a1 isn't dereferenced. You might want to write A.a instead to make the code more intuitive.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What is the equivalent Java for this PHP code?
//print string plus/with variable
$mystring = "this is string " .$string
//print sum one + two
$count = $one + $two
//print sum one*two
$count = $one * $two
It should be like :
String mystring= "this is string " + string; // here `string` is aloso String object
/*
* if count ,one and two all of them are int
*/
int count = one + two;
int count = one * two;
But i would suggest to learn basics of java before starting android. As you know php it will not take long to learn java syntax.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
public static int secret(int value) {
int prod = 1;
for(int i =1; i <= 3; i++) {
prod = prod * value;
}
return prod;
}
What would be the output of:
System.out.println("First secret call: " + secret(5));
System.out.println("Second secret call: " + (2 * secret(6)));
and what does the method secret do
The output would be 125 and then 432. The method, "secret", cubes the number passed into it.
everything fits in a very small screenshot in two windows... try it, you will see it is fun, like playing lego but with more magic!!!