[Solved] Why 2 and -2 instead of 1 and -1? [closed]

You need to understand the concepts of post increment(decrement) and pre increment(decrement). Post increment cout << x++<<endl; You can understand this line as “Return the value of x” + “increment the value of x”. I.e The return value is before the increment. So return 0 and increase the value of x to 1. Pre increment … Read more

[Solved] String Split with comma [duplicate]

Just use Split: string[] yourStrings = s.Split(‘,’); Actually, what I think you’re asking for is a return string like this: “red, blue, green, yellow” To achieve that, you need to use string.Join. Try this: public static string getcolours() { List<string> colours = new List<string>(); DBClass db = new DBClass(); DataTable allcolours = new DataTable(); allcolours … Read more

[Solved] Javascript can implement OOP but Ruby can’t implement functional programming? [closed]

Ruby does have first class functions. What makes you think it doesn’t? From wikipedia: A language that has first-class functions is one where: The language supports constructing new functions during the execution of a program, storing them in data structures, passing them as arguments to other functions, and returning them as the values of other … Read more

[Solved] sorting (constructor) in Java [closed]

You can define a natural ordering for your class IceCream by implementing the Comparator interface. public class IceCream implements Comparator{ // … final String name; final Date date; public Icecream(String name, Date date){ this.name = name; this.date = date; } public int compare(Object o1, Object o2) { return ((IceCream)o1).date.compareTo(((IceCream)o2).date); } } 3 solved sorting (constructor) … Read more

[Solved] random function in Java [closed]

int randomNumber = ( int )( Math.random() * 9999 ); if( randomNumber <= 1000 ) { randomNumber = randomNumber + 1000; Math.random() is a method that generates a random number through a formula. It returns a double however, so casting is required if you want an integer, float, or etc. The if block makes sure … Read more

[Solved] Regular Expressions pattern to extract particular digits from text [closed]

Try this: \b(?:256\d{9}|07[17-9]\d{8})\b Explanation: <!– \b(?:256\d{9}|07[17-9]\d{8})\b Options: ^ and $ match at line breaks; free-spacing Assert position at a word boundary «\b» Match the regular expression below «(?:256\d{9}|07[17-9]\d{8})» Match either the regular expression below (attempting the next alternative only if this one fails) «256\d{9}» Match the characters “256” literally «256» Match a single digit 0..9 … Read more

[Solved] Can’t run MySQL query with an end of the year check [closed]

$gdate = date(“Y-m-d”, strtotime(‘today’)); if($gdate==date(“Y-m-d”,strtotime(‘last day of december’))){ $queryrun=mysql_query( $query); you were checking with d-m-Y which is wrong. both date format wasn’t same and that the query is not running. and also a closing ) bracket was missing. Note: mysql_query will be deprecated. solved Can’t run MySQL query with an end of the year check … Read more

[Solved] Palidrome program is not workig [closed]

scanf(“%d%d%d%d%d”,&a,&b,&c,&d,&e,&f); You should have another %d there. Otherwise f contains a garbage value and it’ll be never equals a. I recommend you to reconsider your code and write something more general, like reading a string instead of individual ints. 3 solved Palidrome program is not workig [closed]

[Solved] Distinction between a data structure’s members being stored by hash value and by index [closed]

Arrays are allocated as single, large blocks of memory and entries are accessed by their indexes. The order of entries is fixed and they need have no particular identity apart from their position in the array. Other more complex data structures allow one to store objects identified and accessed using some sort of key. (Hash … Read more

[Solved] New class object error : Object reference not set to an instance of an object [duplicate]

This is your problem: _cache.TryGetValue(“CountsStats”, out countStats) out will change the object that countStats is pointing to. If it’s found in the cache, then it will be the cached object. Great! If it isn’t, then it will be null. You need to create a new instance in this case. You should change your code to … Read more