You need to sign in to do that
Don't have an account?
Yogesh Dighe.
Any problem in the followigng APEX code??
public class StringArrayTest
{
public void generateStringArray()
{
String[] colors = new List<String>{'red','green','blue'};
for(Integer i=0;i<colors.size();i++)
{
// Write value to the debug log
System.debug(colors[i]+i);
}
}
}
M just fresher in SFDC...
How can i run above code.??
Thanx in Advance :)
{
public void generateStringArray()
{
String[] colors = new List<String>{'red','green','blue'};
for(Integer i=0;i<colors.size();i++)
{
// Write value to the debug log
System.debug(colors[i]+i);
}
}
}
M just fresher in SFDC...
How can i run above code.??
Thanx in Advance :)
public class StringArrayTest {
public static String[] generateStringArray(Integer length) {
String[] myArray = new List<String>();
for(Integer i=0;i<length;i++) {
myArray.add('Test ' + i);
System.debug(myArray[i]);
}
return myArray;
}
}
And go :
Your Name>Developer Console>Debug>Open Execute Anonymous Window > Past it below code and click > Execute..
Integer lenght;
String[] myArray = new List<String>();
for (Integer i=0;i<lenght;i++){
myArray.add('Test' + i);
System.debug(myArray[i]);
}
return myArray;
And see Log... And double click recent log....> Its Give u proper output... display Log...
All Answers
It seems correct and if you just want to execute the code and see the result, you can use the developer console using execute anonymus. Execute just the following code:
https://help.salesforce.com/apex/HTViewHelpDoc?id=code_dev_console_execute_anonymous.htm&language=en (https://help.salesforce.com/apex/HTViewHelpDoc?id=code_dev_console_execute_anonymous.htm&language=en" target="_blank)
Regards
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Shaijan
"Challenge not yet complete... here's what's wrong: Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings."
for challenge try this code
Shaijan
Paste below code in it
Click Execute.
Shaijan
Try the below code on developer console. You are not using the new operator in the your code.
it will work now.
But still that code can't gives me proper output :(
public class StringArrayTest {
public static String[] generateStringArray(Integer length) {
String[] myArray = new List<String>();
for(Integer i=0;i<length;i++) {
myArray.add('Test ' + i);
System.debug(myArray[i]);
}
return myArray;
}
}
And go :
Your Name>Developer Console>Debug>Open Execute Anonymous Window > Past it below code and click > Execute..
Integer lenght;
String[] myArray = new List<String>();
for (Integer i=0;i<lenght;i++){
myArray.add('Test' + i);
System.debug(myArray[i]);
}
return myArray;
And see Log... And double click recent log....> Its Give u proper output... display Log...
Shaijan
StringArrayTest ST = new StringArrayTest();
list<string> myArray = StringArrayTest.generateStringArray(100);
system.debug('************'+myArray);