android java string operation [closed] - java

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.

Related

data structure is range or tuple [closed]

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]

Writing arithmetic code in Java [closed]

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;
// }
//}

If Statement--related with making integers in percentages of other integers [closed]

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
I need to write an if statement where I return the string "Close String" when int d is within 10% of int e. This is what I have now:
public String game(double d, double e) {
if((d>=.95*e)||(d<=e*1.05)) {
return "close string";
} else {
return "other";
}
}
TEST CASE
String game = game(100.0d, 90.0d);
System.out.println(game);
game = game(100.0d, 99.0d);
System.out.println(game);
game = game(100.0d, 100.0d);
System.out.println(game);
EXPECTED OUTPUT
other
close string
close string
CURRENT OUTPUT
close string
close string
close string
Where is the mistake?
I'm not sure exactly what you're asking, but I think you want and instead of or.
(a>=.95*b)||(a<=b*1.05)
a can then be any number, because it will be less than 5% above b, or 5% below b as long as it is a real number.
(a>=.95*b)&&(a<=b*1.05)
a can only be within + or - 5%

how to retrieve value in array from mysql table in java? [closed]

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
i want to store string value in array or in in separate variable using java please short out my problem
Thanks
String a1,a2,a3;
while (resultSet.next()) {
isFound=true;
jLabel2.setText("hello");
String s1=resultSet.getString("Court_Num");
System.out.println(s1);
output s1=: 101
102
103
Desired out put: a1=101
a2=102
a3=103
Your question is confusing I think for 1st record you want a1=101 for 2nd a2=102 etc
int i=1;
while (resultSet.next()) {
if(i==1)
{String s1=resultSet.getString("Court_Num");
System.out.println(a1+"="+s1);}
if(i==2)
{String s1=resultSet.getString("Court_Num");
System.out.println(a2+"="+s1);}
if(i==3)
{String s1=resultSet.getString("Court_Num");
System.out.println(a3+"="+s1);}
i++
The title mentioned using an array. That would look something like this:
String[] a = new String[3];
for(int i=0; resultSet.next(); i++) {
a[i] = resultSet.getString("Court_Num");
System.out.println("a" + i + "=" + a[i]);
}

Considering the following method: [closed]

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!!!

Categories

Resources