Method in class cannot be applied to given types. Required: no arguments
Your getAverage()
method doesn't need any arguments. But you have passed a one when you calling it. That's the error you get in here. If you want to pass an argument, you need to change your getAverage()
method signature like this,
public int getAverage(ArrayList<Integer> grades )
Instead of creating a list inside your method then you can use this grades parameter you passed inside the method.
method in class cannot be applied to given types; required: HashMap<String,Integer>
You should pass map as a parameter in getPostDataString method
protected String doInBackground(Object... params) {
URL url;
String response = "";
try {
url = new URL("http://app.iseemobile.com/imenu/getDistrictRestaurants.php");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(15000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
Map<String, Integer> inputMap = new HashMap<String, Integer>();
map.put("district", 1);
writer.write(getPostDataString(map);
writer.flush();
writer.close();
os.close();
int responseCode = conn.getResponseCode();
if (responseCode == HttpsURLConnection.HTTP_OK) {
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = br.readLine()) != null) {
response += line;
}
} else {
response = "";
}
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
method in class cannot be applied to given type
Look at the method signature:
public Account getAccount(Account account)
↑
It expects an object of type Account
, you cannot write:
this.getAccount()
with no arguments. According to your class, I think you don't need to pass Account
object to the method, so removing it from the method definition should solve your problem.
I highly recommend you to visit The Java™ Tutorials - Defining Methods to better know the basic concepts of Java.
Related Topics
Java.Lang.Noclassdeffounderror: Org/Springframework/Core/Env/Configurableenvironment
Java.Lang.Noclassdeffounderror: Lorg/Apache/Logging/Log4J/Logger; But the Artifact Exists
Spring Data JPA and Exists Query
How to Properly Use Enums With Multiple Values
How to Enable Request Scope in Async Task Executor
In Java, How to Determine If a Char Array Contains a Particular Character
How to Have Each Record of Json on a Separate Line
How to Use Jackson to Deserialise an Array of Objects
How to Increase the Java Heap Size Permanently
Jackson @Jsonproperty Not Working If Property Name Not Equal Field Name
Javax.Validation - Allow Null But Validate If the Value Is Not
Spring Boot - Post Method Not Allowed, But Get Works
How to Solve Liquibase Checksum Validation Fail After Liquibase Upgrade
Java.Lang.Noclassdeffounderror: Org/Json/Simple/Parser/Parseexception With Eclipse and Spring
How a Jar File Can Read an External Properties File
Java Classnotfoundexception With Maven Dependency
Java.Lang.Classcastexception: [Ljava.Lang.Object; Cannot Be Cast to Classname