-2

I have very strange problem in eclipse for java (android programming)

This is ALL of my code : (an array and site of that array into int value)

    int[] Values = new int[]{ 5, 12, 4, 2, 4 };
    int Size = Values.length;
    Log.i(Size);
error --^

eclipse gives this error :

The method i(String, String) in the type Log is not applicable for the arguments (int)

What is the problem ?

How to solve it?

Kala
  • 43
  • 1
  • 6
  • 4
    Problem is well explained in the message you posted. – kosa Jan 06 '15 at 16:01
  • @Nambari i am learning from a video, that videos is ok with that code, but i have problem with it. Just i see error and no error is in videos. – Kala Jan 06 '15 at 16:02
  • Does the video use capital letters for the variable names as in your code? If so, I would probably try to grab a different video... it's teaching you bad habits. – Jon Skeet Jan 06 '15 at 16:03
  • 1
    Nothing wrong in learning from video, just spend few minutes to understand what the message saying instead of simply posting to some forum. That helps you in accelerating your learning. – kosa Jan 06 '15 at 16:04
  • The `Log.i()` method takes two strings as arguments and you are giving it one integer. What do you think you have to change in order to fix your problem? Give it two strings, as intended... – shkschneider Jan 06 '15 at 16:06

3 Answers3

0

Log.i(Size); method expecting Log.i(String,String) and you are giving Log.i(int) that's why it is not compiling.

atish shimpi
  • 4,873
  • 2
  • 32
  • 50
0

The error message pretty much tells you what is wrong: You can't pass a single int to the method i() because it has two String as parameter.

See also the documentation for the Log class in the Android API.

You have to pass two strings as described in the linked documentation. See also How do I convert from int to String? if want to to know how to convert your int to a String.

Community
  • 1
  • 1
André Stannek
  • 7,773
  • 31
  • 52
0

You are passing Log an int. You need to pass it two strings (a tag and message). Reference: http://developer.android.com/reference/android/util/Log.html

mikeorr85
  • 471
  • 5
  • 13