经过对[http://stackoverflow.com/users/1690199/v-k]的良好观察,我改进了结构,尽管语法对我来说看起来是正确的,但我仍然收到 token 错误。更多评论和批评将在这里有用并得到认可。
import de.bezier.data.sql.*;
PostgreSQL pgsql;
Float val;
void setup()
{
size( 100, 100 );
println(val);
}
在类数据库的处理 2 中发现标记错误。
Class Database
{
String user = "user";
String pass = "pass";
String database = "db";
Float val;
Database (Float col) {
val = col;
}
void database_connection( col )
{
//sets up database
pgsql = new PostgreSQL( this, "127.0.0.1", database, user, pass );
if ( pgsql.connect() )
{
pgsql.query( "SELECT col FROM table ORDER BY col DESC LIMIT 1; " );
return( pgsql.getFloat("col") );
}
else
{
println ("failed to connect to the database");
}
}
}
老问题:经过[http://stackoverflow.com/users/1690199/v-k]的大量观察后解决了类结构
导入 de.bezier.data.sql.*; …… …… 为了清楚地说明此问题,删除了旧代码。
最佳答案
类不接受参数。而且它是类(class)而不是类(class)......我错过了什么吗?看,一般样本:
class Database {
String user = "user";
String pass = "pass";
String database = "db";
float val; //by convention no Caps for vars...
// a constructor, which get partameters
Database (float v) {
val = v;
}
// a method
void database_setup() {
//whateverq
}
}//end of Database class
关于java - 挑战 token 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20436115/