subject

I am getting this type of error while compiling java code: error: non-static variable sc cannot be referenced from a static context

Following is my code (Quite Simple)

import java. util. Scanner;
class OOP {

Scanner sc=new Scanner(System. in);

public static void main(String[] args){

System. out. println("Define OOP: ");
String oopdefinition = sc. nextLine();

}

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:50
Apython programming question: assume s is a string of lower case characters. write a program that prints the number of times the string 'bob' occurs in s. for example, if s = 'azcbobobegghakl', then your program should print number of times bob occurs is: 2
Answers: 3
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
question
Computers and Technology, 24.06.2019 21:30
Aobject is used for displaying the results of a question based on stored data. a. query b. report c. table d. form
Answers: 2
question
Computers and Technology, 25.06.2019 08:50
Write multiple if statements: if caryear is before 1968, print "probably has few safety features." (without quotes). if after 1971, print "probably has seat belts.". if after 1991, print "probably has anti-lock brakes.". if after 2002, print "probably has airbags.". end each phrase with period and newline. ex: caryear = 1995 prints:
Answers: 2
You know the right answer?
I am getting this type of error while compiling java code: error: non-static variable sc cannot be...
Questions
question
History, 21.01.2021 23:20
question
Health, 21.01.2021 23:20
Questions on the website: 13722359