interface

Attempt to invoke interface method 'int java.util.List.size()' on a null object How Solve It? [duplicate]

别等时光非礼了梦想. 提交于 2019-12-13 11:30:55
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed last year . Error logs - java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference at in.hareshsaliya.itijobs.Adapter.ListSourceAdapter.getItemCount(ListSourceAdapter.java:115) at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3603) at android.support.v7.widget.RecyclerView.dispatchLayout

robot scenario - java inheritance, interface types and abstract classes [closed]

北城余情 提交于 2019-12-13 11:27:16
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . I would like to create a programme based on a robot scenario, that includes abstract classes, interface types and array lists. Can anyone give me some advice on how to create this scenario (via a UML diagram to show how everything links). This scenario needs to include some complex methods, but I

Enum's and Interfaces

 ̄綄美尐妖づ 提交于 2019-12-13 10:16:21
问题 I am trying to call a certain method (say method called "Mood") associated with a Enum value (e.g. Enum WorkDay : Monday, Tuesday, Wednesday etc.). I can obviously do a select case and call certain methods as below. Public Enum WorkDay Monday Tuesday Wednesday Thursday Friday End Enum Dim CurrentDay As Class1.WorkDay = Class1.WorkDay.Monday Select Case CurrentDay Case Class1.WorkDay.Monday Function_Monday() Case Class1.WorkDay.Tuesday Method_Tuesday() Case Class1.WorkDay.Wednesday Method

Do interfaces have a constructor in Java?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 09:53:04
问题 I know that interfaces in Java are handled by the virtual machine as abstract classes. So, every class in Java, abstract or not has a constructor. Does this mean that interfaces have a constructor too? Because too me on one hand makes sense to have a constructor since they are abstract classes. On the other hand it doesn´t make sense since interfaces don´t have any attributes to initialize. So how does it actually work? 回答1: Interfaces don't have constructors. Their implementations do. 回答2:

How to have a generic interface?

可紊 提交于 2019-12-13 09:49:46
问题 I want to have one interface for data access layer, and implement it for various databases (i.e. MongoDb, SQL Server, etc) public interface IDataAccess { Task InsertEntityAsync<T>(string collectionName, T entity) where T : IData; // the rest } and for a specific database: public class MongoDbDataAccess : IDataAccess { public Task InsertEntityAsync<T>(string collectionName, T entity) where T : IData { throw new NotImplementedException(); } } I could make T to be instead of type StudentEntity

Implementation of different indexers within C# class

做~自己de王妃 提交于 2019-12-13 09:46:17
问题 I'd like to add different indexer implementations in my class : SpecificCollection public class SpecificCollection<T> : ISpecificCollection <T> { public int this[int index] { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public object this[int index] { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } public string this[int index] { get { throw new NotImplementedException(); } set { throw new

Pointer to interface with saving type

北慕城南 提交于 2019-12-13 08:51:06
问题 The shortest way to explain my problem is that code: var i interface{} // I can't change it. In fact this is a function, i = Item{10} // that receives interface{}, that contain object (not pointer to object!) fmt.Printf("%T %v\n", i, i) // fmt.Println(i.(NextValuer).NextVal()) // won't compile i = &i fmt.Printf("%T %v\n", i, i) // there i is pointer to interface{} (not to Item) // fmt.Println(i.(NextValuer).NextVal()) // panics // fmt.Println(i.(*NextValuer).NextVal()) // won't compile But if

When to use Abstract Classes and Interfaces? [closed]

ⅰ亾dé卋堺 提交于 2019-12-13 08:37:29
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . Why we use Interface? When we implement one interface we have to write definition for methods of that interface. So, what is need to implement interface? We can directly write methods in the class. Thanks :) 回答1:

Confusion in marker interface

巧了我就是萌 提交于 2019-12-13 08:06:48
问题 Marker interface means interface which have no methods. Then why we call the Runnable interface as a marker interface, even though it has run() method. And one more thing how many marker interfaces are there in java ? 回答1: Then why we call the Runnable interface as a marker interface We don't. You just made that up. 回答2: Runnable is not a Marker interface. AFAIK, Serializable, Clonable, SingleThreadModel, EventListener, RandomAccess, Remote are Marker Interfaces. 来源: https://stackoverflow.com

hiding internal services from outside world to ensure the correct high-level service is being used [closed]

前提是你 提交于 2019-12-13 07:59:54
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 months ago . I am working on an e-commerce website. I have advertisement entity which include both properties and photos. Properties are written to DB and photos are stored in file system. I have created a WriterService in my infrastructure project, this service is responsible to save an ad... under the hood