在java中我想计算年龄..
我正在使用"jodatime.jar"
LocalDate today = LocalDate.now();
LocalDate birthdate = new LocalDate ("1990-12-12");
Years age = Years.yearsBetween(birthdate, today);
Run Code Online (Sandbox Code Playgroud)
我希望年龄为integer
......它像P25Y那样返回值.如何得到年龄的整数值......我只想要25岁
有没有其他方法来获得日期格式的java年龄..在谷歌我已经尝试了很多,但没有找到任何使用日期格式的正确示例
在我的程序中逻辑如下: -
Input Addition with Output(result)
2 3 5
3 3+4 10
4 3+4+4 15
5 3+4+4+4 20
6 3+4+4+4+4 25
Run Code Online (Sandbox Code Playgroud)
所以,我做了: -
import java.util.Scanner;
public class Addition {
public static void main( String[] args) {
@SuppressWarnings("resource")
Scanner s = new Scanner(System.in);
int result=0;
System.out.print("Enter a number: ");
int inputNumber = s.nextInt();
if(inputNumber==2){
result = inputNumber+3;
}
else{
Addition c=new Addition();
int j = inputNumber-2;
int power=c.pow(4,j);
result = inputNumber+3+power;
}
System.out.print(result);
}
int pow(int c, int d)
{
int …
Run Code Online (Sandbox Code Playgroud) 我使用jsp和css作为样式的<td>
内部<table>
标记.我想要如下代码:
但现在我得到了:
#bengalistorycontainer{
width:100%;
}
table.my-special-table {
width: 10px;
height: 10px;
border: 1px rgb(89,89,89) solid;
}
Run Code Online (Sandbox Code Playgroud)
<table class="my-special-table">
<tr>
<c:forEach begin="1" end="${classfile}" var="i"varStatus="loop">
<c:choose>
<c:when test="${classfile eq i}">
<td>${1} </div></td>
</c:when>
<c:otherwise>
<td><a href="#">${2}</a></td>
</c:otherwise>
</c:choose>
</c:forEach>
<c:if test="${totalpagenumber != 1}">
<td> <a href="#">next</a> </td>
</c:if>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我有一些水果名称存储在一个数组中.如果用户输入已存储在数组中的食物名称,true
则应返回,否则返回false
.
但它只true
在我输入值时返回Mango
,否则总是返回false
,为什么?
这是我的代码:
HTML:
<input type="text" id="value" />
<button onclick="check()">test</button>
<p id="pValue">
</p>
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
var myVar;
check = function() {
myVar = document.getElementById("value").value;
var fruits = ['Banana', 'Orange', 'Apple', 'Mango'];
for(i = 0; i < fruits.length; i++) {
if(myVar == fruits[i]) {
document.getElementById("pValue").innerHTML = "true";
}
else {
document.getElementById("pValue").innerHTML = "false";
}
}
}
Run Code Online (Sandbox Code Playgroud)