如何将形式的字符串转换为03/24/2013 21:54java中的Date对象?
我现在正在尝试不同的技术,将头撞在墙上一段时间.
他们都没有运作良好.
我有两个字符串.
我需要比较它们并获得确切的匹配百分比,
即."四分和七年前"为了"scor and sevn yeres ago"
好吧,我首先将每个单词与每个单词进行比较,跟踪每个单词,以及百分比= count \numOfWords.不,没有考虑拼写错误的单词.
("四"<>"为"即使它很近)
然后我开始尝试比较每个char中的每个char,如果不匹配则递增字符串char(计算拼写错误).但是,我会得到错误的命中,因为第一个字符串可能在第二个字符串中包含每个字符,但不是第二个字符串的确切顺序.("东西可用"<>"stu vail"(但它会回来,低百分比,但是命中.9\11 = 81%))
所以,我然后尝试比较每个字符串中的字符对.如果string1 [i] = string2 [k] AND string1 [i + 1] = string2 [k + 1],则递增计数,并在不匹配时递增"k"(以跟踪误导."for"和"四分"应该以75%的命中率回归.)这似乎也不起作用.它越来越近,但即使完全匹配,它也只会返回94%.当事情真的拼写错误时,它真的搞砸了.(底部代码)
有什么想法或指示吗?
码
count = 0
j = 0
k = 0
While j < strTempName.Length - 2 And k < strTempFile.Length - 2
' To ignore non letters or digits '
If Not strTempName(j).IsLetter(strTempName(j)) Then
j += 1
End If
' To ignore non letters or digits ' …Run Code Online (Sandbox Code Playgroud) 大家好,我开始学习引导程序有一段时间了,
我想为 div 框制作关闭按钮我有这个代码但 X 按钮不起作用:
<div class="panel panel-default">
<table class="table table-hover">
<thead>
<tr style="background-color: lavender;">
<th><button type="button" class="btn btn-primary btn-xs">Share</button></th>
<th><a href="#" class="close" data-dismiss="panel" aria-label="close" id="hide">×</a></th>
</tr>
</thead>
<tbody>
<tr>
<td>Manchester United - Manchester United</td>
<td>2 - 1</td>
</tr>
<tr>
<td>FC Barcelona - Manchester</td>
<td>T1 2+p.p</td>
</tr>
<tr>
<td>Manchester United - Manchester United</td>
<td>2 - 1</td>
</tr>
<tr>
<td>FC Barcelona - Manchester United</td>
<td>2 - 1</td>
</tr>
<tr style="background-color: lightgreen;">
<th>Bet: 2100</th>
<th>Win: 55864</th>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
这是 …
我有 2 个表映射到实体User和Group.
@Entity
@Table(name = "T_COM_USER")
public class User {
private String userName;
@Column(name="F_USERNAME", length=60)
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
Run Code Online (Sandbox Code Playgroud)
@Entity
@Table(name="T_COM_USERGROUP")
public class UserGroup{
private String groupName;
@Column(name="F_GROUPNAME", length=60)
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
}
Run Code Online (Sandbox Code Playgroud)
一个人User可以有很多个Group。我需要对它们进行建模,以便在前端的表格中显示用户及其所有组,如下所示:
+-------+----------------------+
| Users | Groups |
+-------+----------------------+
| User1 | Group1,Group2,Group3 …Run Code Online (Sandbox Code Playgroud) 我想在三个地方放置按钮在图像的顶部
如何将这些按钮放在图像的顶部.
<img src="images/default_image.png" style="width:90%" id="mImage" />
Run Code Online (Sandbox Code Playgroud) 我是hibernate编程的新手请帮帮我,执行下面的文件时遇到问题.我正在使用MySQL数据库.我的错误是
SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder".SLF4J:默认为无操作(NOP)记录器实现SLF4J:有关更多详细信息,请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder.Hibernate:插入UserDetails(userName)值(?)Hibernate:插入UserDetails(userName)值(?)Hibernate:插入UserDetails(userName)值(?)Hibernate:插入车辆(vehiName)值(?)Hibernate:插入车辆(vehiName)值(?)Hibernate:插入UserDetails_vehicle(UserDetails_userID,vehi_vehiID)值(?,?)Hibernate:插入UserDetails_vehicle(UserDetails_userID,vehi_vehiID)值(?,?)Hibernate:插入UserDetails_vehicle(UserDetails_userID, vehi_vehiID)值(?,?)
异常在线程"主要" org.hibernate.exception.ConstraintViolationException:无法在org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)在org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper执行JDBC批处理更新.的java:66)在org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)在org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)在org.hibernate.engine.ActionQueue.executeActions(ActionQueue的.java:188)处org.hibernate.impl在org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51 org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)). SessionImpl.flush(SessionImpl.java:1216)在org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)在org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)在com.annt.java .UserTest.main(UserTest.java:34)引起:java.sql.BatchU pdateException:复制在org.hibernate作为条目 '1' 为键 'vehi_vehiID' 在com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1669)在com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1085) .jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)在org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)... 8个
@Entity
public class UserDetails {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int userID;
@OneToMany
private List<vehicle> vehi = new ArrayList<vehicle>();
public List<vehicle> getVehi() {
return vehi;
}
public void setVehi(List<vehicle> vehi) {
this.vehi = vehi;
}
public int getUserID() {
return userID;
}
public void setUserID(int userID) {
this.userID = userID;
}
private String userName;
public String getUserName() {
return userName;
}
public …Run Code Online (Sandbox Code Playgroud) 我Date在sql数据库中有一个类型的birthdate列
在我的应用程序中,我使用a dateTimePicker来获取出生日期
但是当我试图插入date以下内容时dateTimePicker:
我收到一个错误:
'12'附近语法不正确
当我尝试调试代码时,我发现从中获取的值dateTimePicker是
日期= {3/21/2015 12:00:00 AM}
代码:
//cmd is sql command
cmd.CommandText="INSERT INTO person (birthdate) VALUES("+dateTimePicker.Value.Date+")";
//con is sql connection
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Run Code Online (Sandbox Code Playgroud) 我有这样的集合:
{
"_id":"1321464"
"Sex":"Male"
"Age":"20"
"City":"Toronto" #Maybe this field are not present.
}
Run Code Online (Sandbox Code Playgroud)
我想找到我所有的文件"City"字段不存在.我尝试:
collection.find({"sex":"Male"},{"City":{"$exists": False}},{'Age': 1, '_id':0})
Run Code Online (Sandbox Code Playgroud)
我有这个错误信息:
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 1239, in find
return Cursor(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 125, in __init__
raise TypeError("skip must be an instance of int")
TypeError: skip must be an instance of int
Run Code Online (Sandbox Code Playgroud) 编辑:这个错误仅当我在 Ubuntu 14.04 笔记本电脑上运行游戏时才会发生。当我在 Windows 学校计算机上运行它时,它运行良好。
正常运行时窗口滞后,但当我用鼠标调整窗口大小时停止滞后
我正在尝试用 java 制作一个简单的游戏,但是当我运行它时,它会疯狂地滞后,我查看了代码,并对 System.out.println 和 System.currentTimeMillis 进行了一些检查,并且代码运行不到一毫秒,所以这不是问题。
当我拖动以调整窗口大小并不断更改窗口的大小(大概强制屏幕重绘)时,程序会停止,当我这样做时,它具有非常流畅的动画。
当我的程序运行时,它以平滑的动画开始,然后大约 1 秒后它达到大约 2 FPS,再过一秒达到 1 FPS,然后大约 0.5FPS 并保持在那里,直到我通过调整大小强制重新绘制。窗户
我的代码是:
public class WindowSetup extends JPanel{
private static final long serialVersionUID = 6486212988269469205L;
static JFrame frame;
static JPanel panel;
protected void paintComponent(Graphics g){
super.paintComponent(g);
GameClass.draw(g);
}
public static void main(String[] args) {
frame = new JFrame("Evolver");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
panel = new WindowSetup();
frame.add(panel);
panel.setVisible(true);
frame.setVisible(true);
GameClass.init();
ActionListener al = new ActionListener() {
public void …Run Code Online (Sandbox Code Playgroud) 我们来看一个现实世界的例子吧.
假设,我有三只狗,但一只狗可能与另一只狗不同.
第一只狗喜欢吠叫和吃东西,第二只狗喜欢玩耍和追逐猫,第三只狗喜欢跑步和慢跑(将这些动作视为方法).
我如何在Java中实现它?我必须使用什么,最佳做法是什么?抽象类,接口或它们两者?
正如您在python中所知,函数可以返回多个值
例如:
def myfun():
return 1, 2, 3
Run Code Online (Sandbox Code Playgroud)
我们可以这样称呼它:
a, b, c= myfun()
Run Code Online (Sandbox Code Playgroud)
但是在JAVA中,我们不能返回更多的那个值,所以我们必须创建一个包含我们想要返回的值的对象:
class MyObject {
private Integer a;
private Integer b;
private Integer c;
public Integer getA() {
return a;
}
public void setA(Integer a) {
this.a = a;
}
public Integer getB() {
return b;
}
public void setB(Integer b) {
this.b = b;
}
public Integer getC() {
return c;
}
public void setC(Integer c) {
this.c = c;
}
}
Run Code Online (Sandbox Code Playgroud)
我们的函数将返回此对象
例如:
public MyObject myfun(){ …Run Code Online (Sandbox Code Playgroud)