在Java中通过参数解析数据
我们可以通过Java将mySQL添加到数据中吗 数据表如下所示:在Java中通过参数解析数据,java,mysql,database,Java,Mysql,Database,我们可以通过Java将mySQL添加到数据中吗 数据表如下所示: +----+-------------------+ | ID | Desc | +----+-------------------+ | 1 | personal email %s | | 2 | office email %s | +----+-------------------+ 我们是否可以通过方法将此%s更改为数据并打印输出 像- PrintdataString名称 {} 并获得输出
+----+-------------------+
| ID | Desc |
+----+-------------------+
| 1 | personal email %s |
| 2 | office email %s |
+----+-------------------+
我们是否可以通过方法将此%s更改为数据并打印输出
像-
PrintdataString名称
{}
并获得输出
personal email test@test.com etc.
是的,我们能做到。
请检查以下示例主程序
package com;
public class TestFormat {
/**
* @param args
*/
public static void main(String[] args) {
String s= "personal email %s";
String email = "test@test.com";
System.out.printf(String.format(s,email));
}
}