令牌上的语法错误,而是预期的 variableDeclarator

编程入门 行业动态 更新时间:2024-10-19 06:16:20
本文介绍了令牌上的语法错误,而是预期的 variableDeclarator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
  cv.put(colDeptID, 1);
  cv.put(colDeptName, "Sales");
  db.insert(deptTable, colDeptID, cv);

  cv.put(colDeptID, 2);
  cv.put(colDeptName, "IT");
  db.insert(deptTable, colDeptID, cv);
                    db.close();

使用此代码,在输入每一行并收到此错误后,我在括号下得到一个红色下划线:标记("上的语法错误,请删除此标记.

With this code, I am getting a red underline under the parenthesis after put in every line and getting this error: Syntax error on token "(", delete this token.

我也收到一条错误消息:令牌上的语法错误,而是预期的 variableDeclarator.有任何想法吗?我已经尝试了所有我知道的方法,但都没有奏效.

I also get an error that says: Syntax error on tokens, variableDeclarator expected instead. Any ideas? I've tried everything I know to do, and none of it worked.

我也得到关闭"时出现语法错误,此令牌后应有标识符

I also get Syntax error on "close", identifier expected after this token

我从教程中复制并粘贴了这段代码,所有评论都说它有效,但我遇到了很多问题.感谢您如此快速的回复.

I copy and pasted this code from a tutorial and all the comments said it worked, but I've had quite a few problems out of it. Thanks for such quick replies.

推荐答案

仅声明,例如:

SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();

可以直接在类声明中.非声明,例如:

can be directly inside a class declaration. Non-declarations, such as:

  cv.put(colDeptID, 1);
  cv.put(colDeptName, "Sales");
  db.insert(deptTable, colDeptID, cv);

必须在方法、构造函数、初始化块或静态初始化块中.在这种情况下,它们可能应该在构造函数或方法中.

must be inside a method, constructor, initializer block, or static initializer block. In this case they should probably be in a constructor or method.

这篇关于令牌上的语法错误,而是预期的 variableDeclarator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 13:30:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1410131.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   语法错误   variableDeclarator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!