i'm facing the error please help me sort it out,as i have my project to be submitted....please...   import java.util.*;  public class project {          public static void intro1() {     Scanner obj= new Scanner((System.in));     System.out.println(" This converter will be related as follows" );     System.out.println(" 1.Digital Storage" );     System.out.println(" 2.Distance(length)" );     System.out.println(" 3.Currency" );     System.out.println(" 4.Temperature" );     System.out.println(" Please choose your option,which you want to be converted,please type that number related" );     int q= obj.nextInt();     System.out.println(" Command received!....executing..." );     String w=Integer.toString(q);     String a=(w.trim());     int n=Integer.parseInt(a);     switch(n)     {         case 1:         {             //some codes here          }         break;         case 2:         {             //some codes here           }         break;         case 3:         {          }         break;         case 4:         {             //some codes here `enter code here`         }         break;          default:         {             System.out.println(" I'm sorry you have chosen the wrong option...please enter again" );             {                 intro1();             }         }     }     exit(); }  public static void exit() {     Scanner obj=new Scanner (System.in);     System.out.println("to continue type 'cont' or else type 'exit'");     String pi=obj.nextLine();     if(pi=="exit")     {         System.exit(0);     }     else      {         intro1();     } } }   i'm facing the error please help me sort it out,as i have my project to be submitted....please...
93
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
38323
This code compiles but in preview, it shows an error Invalid selectOptions found. Use SelectOption type in Apex.   public list&lt;student__c&gt; myStud = new list&lt;student__c&gt;();    List&lt;student__c&gt; stud_qry = new List&lt;student__c&gt;();     public list&lt;student__c&gt; getStud(){         stud_qry =  [select Id, First_Name__c, name from Student__c];          for(student__c getEm : stud_qry){           myStud.add(new student__c(Name = getEm.first_name__c+' ' + getEm.name));            }            return myStud;    }   VFP  &lt;apex:outputText &gt;Select Student:&lt;/apex:outputText&gt;                 &lt;apex:selectList size="1"&gt;                      &lt;apex:selectOptions value="{!Stud}"/&gt;                 &lt;/apex:selectList&gt;
29173
How do you solve the following error when creating a simple post?     It looks like your post is mostly code; please add some more details
12184
I'm trying to get an understanding of what the the java keyword this actually does. I've been reading Sun's documentation but I'm still fuzzy on what this actually does.
20076
I was wondering if there was an alternative to itoa() for converting an integer to a string because when I run it in visual Studio I get warnings, and when I try to build my program under Linux, I get a compilation error.
57217
Compiling the following code and got the error of type illegal.  int main() {     // Compilation error - switch expression of type illegal     switch(std::string("raj"))     {     case"sda":     } }   You cannot use string in either switch or case. Why? Is there any solution that works nicely to support logic similar to switch on strings?
24218
Is this functionality going to be put into a later Java version?  Can someone explain why I can't do this, as in, the technical way Java's switch statement works?
66985
When I run the attached code I get this error:  ************************************ Missing \endcsname inserted. &lt;to be read again&gt;                     \c@float@type  l.23 \end{algorithm} ************************************   Any help would be highly appreciated.  \documentclass[aip, amsmath, amssymb, reprint]{revtex4-1}  \usepackage{graphicx} \usepackage{dcolumn} \usepackage{bm} \usepackage{float} \usepackage{algorithm} \usepackage{algpseudocode}  \begin{document}  \begin{algorithm*}   \caption{Hello}   \label{EPSA}    \begin{algorithmic}[1]    \State $T_m= \min\limits_k (T_c(k)),  k_m= \arg\min\limits_k (T_c(k))$    \end{algorithmic} \end{algorithm*}  \end{document}
123258
@RestResource(urlMapping='/Merchandise/*') global with sharing class MerchandiseManager {      @HttpGet     global static Merchandise__c getMerchandiseById() {         RestRequest req = RestContext.request;                 String merchId = req.requestURI.substring(                                   req.requestURI.lastIndexOf('/')+1);         Merchandise__c result =                         [SELECT Name,Description__c,Price__c,Total_Inventory__c                         FROM Merchandise__c                          WHERE Id = :merchId];         return result;     }      @HttpPost     global static String createMerchandise(String name,         String description, Decimal price, Double inventory) {         Merchandise__c m = new Merchandise__c(             Name=name,             Description__c=description,             Price__c=price,             Total_Inventory__c=inventory);         insert m;         return m.Id;     } }   i am trying to execute these from postman,    but throwing below error,how i can authenticate,please help urgent requirement.     {       "message": "Session expired or invalid",       "errorCode": "INVALID_SESSION_ID"   }
92088
public class WrapperTest {      public static void main(String[] args) {          Integer i = 100;         Integer j = 100;          if(i == j)             System.out.println("same");         else             System.out.println("not same");     }     }   The above code gives the output of same when run, however if we change the value of i and j to 1000 the output changes to not same. As I'm preparing for SCJP, need to get the concept behind this clear. Can someone explain this behavior.Thanks.
100785
I got an Int16 value, from the database, and need to convert this to an enum type. This is unfortunately done in a layer of the code that knows very little about the objects except for what it can gather through reflection.  As such, it ends up calling Convert.ChangeType which fails with an invalid cast exception.  I found what I consider a smelly workaround, like this:  String name = Enum.GetName(destinationType, value); Object enumValue = Enum.Parse(destinationType, name, false);   Is there a better way, so that I don't have to move through this String operation?  Here's a short, but complete, program that can be used if anyone need to experiment:  using System;  public class MyClass {     public enum DummyEnum     {         Value0,         Value1     }      public static void Main()     {         Int16 value = 1;         Type destinationType = typeof(DummyEnum);          String name = Enum.GetName(destinationType, value);         Object enumValue = Enum.Parse(destinationType, name, false);          Console.WriteLine("" + value + " = " + enumValue);     } }
33779
I came across some very strange behaviour when working with a Map with Decimal keys today. It seems like the Decimal type can't handle Integer assignments properly, but allows them nonetheless. I've written some example code demonstrating the problem:  Map&lt;Decimal, String&gt; m = new Map&lt;Decimal, String&gt;(); m.put(1234, 'Integer key');  m.put(1234.0, 'Decimal key'); m.put(1234.5, 'Decimal Unique key');  System.debug(m.get(1234));      // =&gt; Integer key, why was this not overwritten if 1234 == 1234.0? System.debug(m.get(1234.0));    // =&gt; Decimal key System.debug(m.get(1234.5));    // =&gt; Decimal Unique key  System.debug(m);        //Order of insertion matters, newest value does not override existing one but is not shown on map printout... for(Decimal d : m.keySet()){     System.debug(d);    //...unless you print it out yourself, because this loop shows all the keys }  //Sanity check System.debug(1234 == 1234.0); //True  //Digging deeper Decimal fake_d = 1234; Decimal real_d = 1234.0; Integer real_i = 1234; //Integer fake_i = 1234.0; //Illegal assignment, typechecking only works one way, it seems  //More sanity checks System.debug(fake_d == real_d); //True (Except when used in a Map, apparently) System.debug(fake_d == real_i); //True  System.debug(m.get(real_i)); // =&gt; Integer key System.debug(m.get(fake_d)); // =&gt; Integer key, even with fake_d explicitely declared as a Decimal type, it still pretends to be an Integer. System.debug(m.get(real_d)); // =&gt; Decimal key   I found this behaviour when I tried to fetch a value from a map using a Decimal sObject field, only to find that the keys I used to populate the Map (coming from a different Decimal field) were interpreted as Integers since they had no real decimal digits.  Maybe using Decimals as Map keys is not supported for some reason? Is it expected behaviour for 1234 and 1234.0 being distinct values in this case or is this an oversight in the Map implementation?
71247
List&lt;String&gt; nameList = new List&lt;String&gt;(); DropDownList ddl = new DropDownList();   List is populated here, then sorted:  nameList.Sort();   Now I need to drop it into the dropdownlist, which is where I'm having issues (using foreach):  foreach (string name in nameList){     ddl.Items.Add(new ListItem(nameList[name].ToString())); }   No workie - any suggestions? It's giving me compile errors:  Error - The best overloaded method match for 'System.Collections.Generic.List&lt;string&gt;.this[int]' has some invalid arguments   Error - Argument '1': cannot convert from 'string' to 'int'
9770
I'm sure you all know the behaviour I mean - code such as:  Thread thread = new Thread(); int activeCount = thread.activeCount();   provokes a compiler warning.  Why isn't it an error?  EDIT:  To be clear: question has nothing to do with Threads.  I realise Thread examples are often given when discussing this because of the potential to really mess things up with them.  But really the problem is that such usage is always nonsense and you can't (competently) write such a call and mean it.  Any example of this type of method call would be barmy.  Here's another:  String hello = "hello"; String number123AsString = hello.valueOf(123);   Which makes it look as if each String instance comes with a "String valueOf(int i)" method.
17519
I have a string containing the , and I need to convert it to a Java Date object.  String date = "1081157732"; DateFormat df = new SimpleDateFormat(""); // This line try {   Date expiry = df.parse(date);  } catch (ParseException ex) {   ex.getStackTrace(); }   The marked line is where I'm having trouble. I can't work out what the argument to SimpleDateFormat() should be, or even if I should be using SimpleDateFormat().
110820
I'm currently making a callout to a 3rd party vendor and I'm getting a huge response. What is currently messing me up is this section:   "MessageSeq":13,"Description":"config file: config-qa1.txt\"","MessageTS":"2014-02-17T14:46:58","MessageLevel":4,"IsSystemMessage":false   As you can see here, the portion at the end of the Description value is ended with backslash double quote. If I attempt to parse this via the JSONParser I get an exception. Does anyone have an recommendations on how to resolve this?  Exception Message:  System.JSONException: Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries at [line:1, column:3699]  Updated with sample Code   public class ResponseWrapper{     // fields from JSON to auto map     public Integer messageSeq;     public String Description;     public String messageTS;     public Integer messageLevel;     public Boolean isSystemMessage;     // parsing fields     private ResponseWrapper theResponse;     private JSONParser parser;      public void parse(String jsonString){         parser = JSON.createParser(jsonString);         parseJSON();     }      private void parseJSON(){            while (parser.nextToken() != null) {             if (parser.getCurrentToken() == JSONToken.START_OBJECT) {                 theResponse = (ResponseWrapper)parser.readValueAs(ResponseWrapper.class);                            }         }     } }  String responseString = '{"MessageSeq":13,"Description":"config file: config-qa1.txt\"","MessageTS":"2014-02-17T14:46:58","MessageLevel":4,"IsSystemMessage":false}'; system.debug('\n\nBEFORE\n' + responseString); ****Place code in here to test such as ReplaceALL*** ResponseWrapper parser = new ResponseWrapper(); parser.parse(responseString);
104592
I am running some script which passing the string argument and I want to do if else statement shown as below:  if [ $1 != '' ] &amp;&amp; [ $2 != '' ] then      do something.....   but it shown Error too many argument. Why?