Method in Class Cannot Be Applied to Given Types. Required: No Arguments

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



Leave a reply



Submit